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?
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?