Hi everybody,
I am moving a php site to new hosting, and what was working fine on the old hosting is now broken on new hosting. The problem is that session_start is always creating a new session, even though one exists. I can see that the cookie is created just fine locally on login, and the matching session file is created on the server. But once I go to a new page, my checklogin() calls session_start which returns a new empty session, and I am automatically logged out.
Here is how I create the session during login:
[PHP]if ($rs->RecordCount() == 1) { // Found a partner
session_start();
$_SESSION['real-usr'] = $usr;
}[/PHP]
Here is how I check that the user is logged in:
[PHP]function checkLogin() {
session_start();
if (empty($_SESSION['real-usr'])) {
echo "Session expired. Please login";
include("login.php");
die();
}
}[/PHP]
Note that it isn't shared hosting, so there shouldn't be a problem with other processes deleting the temporary session files. (Plus I can see that the temp files are still there.)
I am using PHP 5.2.2. Here is an exerpt from phpinfo()
session
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 On On
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain .semoptimizer.com .semoptimizer.com
session.cookie_httponly Off Off
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 C:\Temp C:\Temp
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid 0 0
If anybody can give me a hand, it would be much appreciated. I have been doing google searches all day and investigating different options, but haven't figured anything out.
Thanks,
jessica