Johny
Johny

Reputation: 401

PHP This webpage has a redirect loop

I' am working on a custom website. After successful login this is the condition below is run when user is successfully logged in which will redirect user to dashboard. Else if the session is not isset then it will redirect to admin page. I' am getting error on the screen "PHP This webpage has a redirect loop" But when I uncomment this code below everything works fine.

security.php

<?php
/*
    CHECK FOR ANY SESSIONS
*/
    session_start();
    if(isset($_SESSION['session_id'])){

         $session_id = $_SESSION["session_id"];

            header("Location: /admin/dashboard");
            exit();

    } else {
        header("Location: /admin");
        exit();
    }
?>

I have tried "ob_start" but no luck at all...

Upvotes: 0

Views: 5902

Answers (2)

Sentinel
Sentinel

Reputation: 207

if you have the /admin/dashboard pass trough the security.php wont it forever set header("Location: /admin/dashboard"); ?

Upvotes: 0

Fyntasia
Fyntasia

Reputation: 1143

This message probably means that there is a redirect from either /admin/dashboard or /admin back to your script. This will throw your script into a loop.

Check these scripts for possible redirects.

Upvotes: 3

Related Questions