Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sessions Question

Status
Not open for further replies.

beeman000

Programmer
Mar 21, 2005
1
US
I just switched an application i wrote to a new server. According to phpinfo(), the new server has Session Support enabled. When i call session_id(), i get a session id, but if i create a session variable, and then go to another page, the variable does not exist. For example I used the following sample code i got from the web:

test1.php
<?php
session_start();
$_SESSION['userid'] = "foo";
print "Session id is: " . session_id();
print "<a href='test2.php'> go to next page </a>";
?>

test2.php
<?php
session_start();
print "Welcome" . $_SESSION['userid'] . "<br />";
print "You have got to page 2 with these information stored in the session: " . $_SESSION['userid'] . " and your session is still: " ;
echo session_id();
?>

When i load these pages to my server, the session_id shows up in my browser, but the $_SESSION['userid'] is blank on test2.php

Here is the session info from phpinfo();
Session Support enabled
Registered save handlers files user
Directive Local Value Master Value
session.auto_start Off Off
session.bug_compat_42 Off Off
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 1000 1000
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /var/lib/php/session /var/lib/php/session
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid Off Off

I assume this has something to do with the way that php is configured on the new server, but dont know anything else....Can someone please help?
 
Maybe there is no more space on your server to keep Session information saved? I took a very quick look through the script, and couldn't find anything wrong.
 
Try the following:
The output of the phpinfo() shows the path to the stored session information. Try to go there in the shell and inspect if your session files are there.
Alternatively use ini_set and set session.save_path to a folder within your area on the server where you can inspect the session files.

Are you configuring the server? Then make sure that the user as which the web server runs has read/write access to the session storage area. The one shown above is not a 'common' one, I'd move it somwhere in /var/temp/ or /temp/
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top