Reputation: 1
In sample.php file i am setting and printing the values
session_start();
$_SESSION['userid'] = "4";
echo session_id();
echo ' ' . $_SESSION['userid'] . ' ';
print_r($_SESSION);
The output is
tv0p126mg6q8ksvhbueq029567 4 Array ( [userid] => SimpleXMLElement Object ( [0] => 4 ) )
In second.php file i am trying to access userid session but its not set
session_start();
echo session_id();
echo ' ' . $_SESSION['userid'] . ' ';
print_r($_SESSION);
Here my output is
tv0p126mg6q8ksvhbueq029567 Array ( )
Help me out in getting the session value in second.php file
Upvotes: 0
Views: 108
Reputation: 4629
Maby not enough space on the server to store session data (if it's linux var directory by default ..i think). Check your server log, there should found your answer ;)
Your code should work by the way.
Upvotes: 0
Reputation: 324650
It looks like your sessions are not being saved on the server. Check php.ini settings concerning sessions, and double-check that the location session files are being created in exists and is writable - it happened to me that I had a typo in the path and sessions weren't working as a result... had me stuck for hours!
Upvotes: 1