Click here to Skip to main content
15,894,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im stuck with a piece of code for many hours but still couldn't find a error.

I'm setting a session variable in one page and doing it echo in another page but there isn't any output in the second page.

page1.php

session_start();
$_SESSION['id'] = 1;
echo $_SESSION['id'];
header("Location: page2.php");
?>

output of page1.php

1


page2.php

session_start();
echo " $_SESSION['id']" ;
?>

output of page2.php

No output.


Why this happens and what to do get the output in page2.php as 1 ??
Posted
Updated 12-Feb-14 4:15am
v2

1 solution

change:
echo " $_SESSION['id']" ; 

to
echo $_SESSION['id'];
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900