session variable not working

krahny

New Member
Messages
25
Reaction score
0
Points
0
I have a session variable set on one page, and I know it gets set because it works for that page, but whaen I go to a new page, it seems as though it's not set.

Here's the code that sets the variable:

session_start();
$_SESSION['logging']=$_POST['username'];

Here's the code that's on both of the pages, but only writes the cookie on the first one:

if(isset($_SESSION['logging'])){
echo $_SESSION['logging'];
}

Could someone please help?
 

descalzo

Grim Squeaker
Community Support
Messages
9,372
Reaction score
326
Points
83
Do you have session_start() on the second page?
Are you sure nothing has been sent to the browser before you call session_start() on the second page?
 

krahny

New Member
Messages
25
Reaction score
0
Points
0
No, I forgot to put session_start() on the second page. Thanks!
 
Top