Take me, if this looks like the other questions posted here, I already went through all the answers provided, but did not solve my problem. I reduced my problem to a minimum.
- I have two pages (page1.php, page2.php)
- Page1.php creates a session variable, and if a session variable is set, it sends the browser to Page2.php
- On page2.php, the browser should display the value of the session variable set in Page1. Php
- My problem is that page2.php displays the session variable as not set.
- I tried all the solutions sent by other users when the stack overflowed, as you can see from my code below:
page1.php
<?php
session_start();
$_SESSION['mysession'] = "Hello";
if(isset($_SESSION['mysession'])){
session_write_close();
header("Location: page2.php?PHPSESSID=".session_id());
exit();
} else {
echo "Session Not Set";
}
?>
page2.php
<?php
session_start();
session_id($_GET['PHPSESSID']);
if ( isset ($_SESSION['mysession']) )
echo $_SESSION['mysession'];
else
echo "Session not set!";
?>
source
share