Forum Moderators: coopster

Message Too Old, No Replies

Header Redirection

Header not redirecting properly?

         

Spontan

3:55 am on Jun 20, 2004 (gmt 0)

10+ Year Member



My problem is this. This page load correctly upon loading. However if i just go back to this page after logging in. THe page returns blanks and does not forward me to the new location. the variable login is either 0 for 1. 0 for not logged in and 1 for logged in. After log in it is set to 1. If i am not logged in and try to go to page there the if just says!sesss_ etc...it redirects back to index fine. So i dont' understand why this doesnt' redirect into the logged in pages.

I read around as best as i could and i couldn't determine much. All i can think of that works as an explaination is the php script before the redirect intereferes but im not sure how.

Was wandering if anyone could explains whats going on and how to fix it. I'd like to keep my options within php. Meaning avoid javascript redirect ;)

<?php
session_start(); //start session
if($_SESSION['login'])
{
Quote:
header("Location: loggedin.php");

}
else
{?>

//display webpage

<?php
}
?>

P.S. Kinda new so sorry if i didnt' post it in the best format ever

Timotheos

5:41 am on Jun 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You know I don't think this will solve your problem but I think you should also check to see if the variable is set.

if(!isset($_SESSION['login']) ¦¦ $_SESSION['login'] == 0)
{
Quote:
header("Location: loggedin.php");

}

BTW, what's the 'Quote:' line for?

Zipper

2:37 pm on Jun 21, 2004 (gmt 0)

10+ Year Member



if(!isset($_SESSION['login']) ¦¦ $_SESSION['login'] == 0)
{
Quote:
header("Location: loggedin.php");

}

Doesn't it have to be the other way around?

Spontan

6:31 pm on Jun 21, 2004 (gmt 0)

10+ Year Member



The way i fixed it because i gave up.

header("loggedin.php");

is now

include("loggedin.php");

tada fixed...lol..no need to redirect