Saturday, 7 September 2013

Page refresh cause a session cookie to be created in Codeigniter and a record inserted in the session table

Page refresh cause a session cookie to be created in Codeigniter and a
record inserted in the session table

Reading through so many things but haven't found a solution to my problem.
I use ajax requests to authenticate my users on the website. The login and
logout ajax requests work absolutely fine. The login call creates the
session cookie and stores data in the session table. The logout call
clears the cookie and removes the data from the database. All this works
as expected.
I'm testing this on my localhost with WAMP server.
The most irritating thing is if all cookies are cleared and the session
table is completely empty, when I refresh my webpage a session cookie gets
generated from somewhere. Along with that I also get a record inserted
into the session table with the same session id as in the browser cookie.
There is no user data present in that database record so I'm really
confused and frustrated as to from where is this cookie getting created.
I'm autoloading my session library. As of now I don't want to go back to
native sessions so please suggest.
session configuration is as below. Can sess_update() help here somehow.
$config['sess_cookie_name'] = 'cisession';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = TRUE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = TRUE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;

No comments:

Post a Comment