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($_SESSIO N['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_st art Off Off
session.bug_com pat_42 On On
session.bug_com pat_warn On On
session.cache_e xpire 180 180
session.cache_l imiter nocache nocache
session.cookie_ domain .semoptimizer.c om .semoptimizer.c om
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_divi sor 1000 1000
session.gc_maxl ifetime 1440 1440
session.gc_prob ability 1 1
session.hash_bi ts_per_characte r 5 5
session.hash_fu nction 0 0
session.name PHPSESSID PHPSESSID
session.referer _check no value no value
session.save_ha ndler files files
session.save_pa th C:\Temp C:\Temp
session.seriali ze_handler php php
session.use_coo kies On On
session.use_onl y_cookies Off Off
session.use_tra ns_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
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($_SESSIO N['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_st art Off Off
session.bug_com pat_42 On On
session.bug_com pat_warn On On
session.cache_e xpire 180 180
session.cache_l imiter nocache nocache
session.cookie_ domain .semoptimizer.c om .semoptimizer.c om
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_divi sor 1000 1000
session.gc_maxl ifetime 1440 1440
session.gc_prob ability 1 1
session.hash_bi ts_per_characte r 5 5
session.hash_fu nction 0 0
session.name PHPSESSID PHPSESSID
session.referer _check no value no value
session.save_ha ndler files files
session.save_pa th C:\Temp C:\Temp
session.seriali ze_handler php php
session.use_coo kies On On
session.use_onl y_cookies Off Off
session.use_tra ns_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
Comment