Welcome Guest, Not a member yet? Register   Sign In
Help! Unexpected session behaviour - constantly reloading


I'm having trouble using the session library. For some reason, my sessions simply do not last, and are reloaded with the page. I'm monitoring the session_id after login, and every time I refresh the page it changes, rather than staying the same. Subsequently any information I stored in the session is gone, and the session is useless. I managed to find a thread created in 2010 where this problem was prominent, however I wasn't able to resolve the issue and I can no longer find the thread.

I did however read that the issue was with using localhost, so I am now using (apparently a period or two is required in the domain). I do not have the database enabled for these sessions.

Can anyone help?

config: http://pastie.org/3989153

Sample code:
$this->session->set_userdata('test1', $test1);
$this->session->set_userdata('test2', $test2);

// redirect the user to the home page

// code for next page, works fine upon the initial redirect, then
// breaks when page is refreshed. test1 no longer exists and the session_id
// changes for each page refresh
echo $this->session->userdata('test1');
echo $this->session->userdata('session_id')

Got a working test case together, and manage to locate where my problem was in production. Problem solved, this thread may be locked.


When a page is loaded, the session class will check to see if valid session data exists in the user's session cookie. If sessions data does not exist (or if it has expired) a new session will be created and saved in the cookie. If a session does exist, its information will be updated and the cookie will be updated. With each update, the session_id will be regenerated.

weboap, you should use [ quote ] instead of [ code ] for stuff like that.

aaronds, you should post what the problem and solution was in the future, in case someone else has a similar situation and is searching for an answer.

Theme © iAndrew 2016 - Forum software by © MyBB