[eluser]pornnarnold[/eluser]
I've got a rather serious problem with CI session data disappearing.
If I set userdata on one page, I can echo it out on the same page after I've set it no problem.
If I redirect to another page or if I just physically type in the address, the session data can no longer be called.
This was all working perfectly on our previous server. We've just moved to a new server and it no longer works.
I've tried it with or without the database, I've tried with and without encrypted cookies.
I've looked at the php server configuration and I can't see anything that I expect could be causing it but it must be a server configuration as I've used identical code on the old server for ages and never had a problem with it.
Interestingly, I've got sites using CI 1.7.2 using the exact same code and they work fine on the new server. The ones that seem to not work are using 2.0.2.
Here's the session config at the moment:
Code:
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
Records are being created in the database for the sessions.
Here's some test code from my home controller:
Code:
public function test()
{
$this->session->set_userdata('test', 'test');
redirect('home/test2');
}
public function test2()
{
echo $this->session->userdata('test');
}
If I load 'test' it redirects to 'test2' but does not display any data. If I turn off the redirect and echo the session userdata it displays 'test'.
Here is a snapshot of the 'session' module from my phpinfo.
As far as I can see it is identical to the previous server where it worked.
Code:
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 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_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 /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
Here is the structure of my session table:
Code:
CREATE TABLE `ci_sessions` (
`session_id` varchar(255) NOT NULL DEFAULT '0',
`ip_address` varchar(255) NOT NULL DEFAULT '0',
`user_agent` varchar(255) NOT NULL,
`last_activity` int(10) unsigned NOT NULL DEFAULT '0',
`user_data` text NOT NULL,
PRIMARY KEY (`session_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
I increased the varchar limit to 255 for all fields just to make sure.
I load the session library in autoload.php.
I've checked the server time and it is currently correct.
I've tried this in Chrome, Firefox and IE and it works in none of them.
We're on PHP Version 5.3.6.
I've got full error reporting on and no errors are raised at any point.
Has anyone got any idea what could be different on the new server compared to the old server?