Welcome Guest, Not a member yet? Register   Sign In
Strange session behaviour in chrome
#1

[eluser]phatphug[/eluser]
I've noticed that my sessions do not appear to work properly in Chrome.

Originally I was storing sessions in the DB, and I noticed that as soon as I started using session->set_userdata, chrome would create a new session every time I loaded the page.

To simplify things, I've turned off DB sessions. My config is as follows:
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']    = FALSE;
$config['sess_table_name']        = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']    = 300;

$config['cookie_prefix']    = "";
$config['cookie_domain']    = ".domain.com";
$config['cookie_path']        = "/";
$config['cookie_secure']    = FALSE;

To test, I've made a very simple controller:
Code:
$this->load->library('session');
echo "<p>test_sess = '".$this->session->userdata('test_sess')."'</p>";
$this->session->set_userdata('test_sess', 'test var');

In firefox and all other browsers I've tried you get:
1st hit - test_sess = ''
2nd hit - test_sess = 'test var'
3rd hit - test_sess = 'test var'

In chrome you get:
1st hit - test_sess = ''
2nd hit - test_sess = 'test var'
3rd hit - test_sess = ''
nth hit - test_sess = ''

Analysing the logs both browsers generate identical results except for the following line from Chrome:
ERROR - 2011-05-25 12:17:40 --&gt; The session cookie data did not match what was expected. This could be a possible hacking attempt.

Any idea as to what is causing this? I'm not sure what to try next.

thanks
#2

[eluser]phatphug[/eluser]
Sorry, forgot to give a few extra details...

I'm using CodeIgniter 2.0.2 on Apache Linux, PHP is 5.2.13
#3

[eluser]phatphug[/eluser]
I've figured this out after lots of head scratching...

I have two installations of CI running, one on /public_html and another on public_html/development (so that dev work doesn't impact the live site)

This means when I visited /development, a session was being created in both instances of CI. Since both were using the same cookie name, this was causing havoc in Chrome/Safari (Webkit).

I've given each install unique cookie prefix's now to fix this.




Theme © iAndrew 2016 - Forum software by © MyBB