I've just bought some new server space and am migrating a very simple PHP app to it that works fine on my other server.
For some reason the session data is not being stored in the $_SESSION variable between pages on the new server. I have looked at this similar SO article and many others to try and fix the issue.
I can confirm that:
- The session stuff is working fine on my other site. I have looked into the directory defined by session.save_path and there are loads of session files in there (on the OLD server).
- I have echoed the contents of the $_SESSION variable at the end of a page, and it is holding the correct data, it's just not being saved.
- I have echo'd session_id() for every page and get the same output.
- I have had a look in the folder specified by the NEW server's session.save_path folder (/usr/lib/php/session) and there aren't any files in there. I have checked the permissions and it's set at drwxrwx---, which should mean that the php program can write to it, right?
- I have no .htaccess file.
- I am running CentOS 5.5
This is from the relevant part of the phpinfo() output:
Session Support enabled
Registered save handlers files user
Registered serializer handlers php php_binary wddx
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.hash_bits_per_character 5 5
session.hash_function 0 0
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 0 0
I've contacted the hosting company and they won't look into it because they say it's a software issue and it's not a managed account. Grrrrr...
Just so you can see some code that isn't working, I have stolen code from the article I have linked to:
// info.php
<?
session_start();
$_SESSION['ID'] = "112233";
$_SESSION['token'] = "mytoken";
print $_SESSION['ID'];
print $_SESSION['token'];
?>
<a href="info2.php">info 2</a>
and one called info2 with this code:
// info2.php
<?
session_start();
print $_SESSION['ID'];
print $_SESSION['token'];
?>
<a href="info.php">info</a>
result is printing the array data in info.php, but no output in info2.php (apart from the link of course).
Many thanks in advance for any help.