Reputation: 87
Why my session variable is not passing between these 2 pages?
<?php
session_start();
$_SESSION["test"]= "12345";
echo "<a href='8.php'>move to another page</a>";
?>
second webpage 2.php
<?php
echo $_SESSION["test"];
?>
The session variable is empy in the second page
Upvotes: 0
Views: 1178
Reputation: 334
you need to set session_start()
on every page on which you want to see $_SESSION
array. It is nice to have one file in which you will set session_start()
and include it on every page on which you want to use sessions.
Upvotes: 1
Reputation:
Why my session variable is not passing between these 2 pages?
Add the session_start()
to your webpage2.php
<?php
session_start();
echo $_SESSION["test"];
?>
Read more info about session here
Upvotes: 0