Welcome Guest, Not a member yet? Register   Sign In
CI sessions + IE + browser closed = session/cookie vanished!
#1

[eluser]stu_chilli[/eluser]
I have a project where I have to store some items in a session and then allow the visitor to go off, close their browser and eventually when they come back to the site that session information is still there.

as CI doesn't use native sessions and instead afaik uses it's own cookie based implementation this shouldn't be an issue?

In basic terms my code looks like:

1. Put something in the session
Code:
$this->CI->session->set_userdata('firstname','John');

2. after the person comes back to the site run:
Code:
echo $this->CI->session->userdata('firstname');

which outputs 'John'.

This works absolutely fine on FF/Chrome/Safari but in IE everytime the browser windows restarts it either wipes the cookie or doesn't pick it up and so the echo outputs nothing. I also see that the session_id has changed.

My Config looks like:
Code:
$config['sess_cookie_name']  = 'cisession';
$config['sess_expiration']  = 0;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name']  = 'ci_sessions';
$config['sess_match_ip']  = FALSE;
$config['sess_match_useragent'] = FALSE;
$config['sess_time_to_update'] = 300;


does anyone have any idea why this wouldn't work in IE?
#2

[eluser]stu_chilli[/eluser]
ok slight update - this isn't a CI problem, it's an IE problem.

With standard cookies and no other code on the site i can replicate the issue with IE. When it closes it ditches the cookie when it next starts.

Does anyone know how to stop IE doing this?
#3

[eluser]stu_chilli[/eluser]
I've found the solution. Nothing was wrong with the config above but the 2 IE browsers I was using both had the option to clear history/cookies/cache upon exit ticked.




Theme © iAndrew 2016 - Forum software by © MyBB