Welcome Guest, Not a member yet? Register   Sign In
CI sessions and AJAX

I've a setup, where the CI session table is updated correctly whenever I call a AJAX function, but the session cookie doesn't get updated. Is there a work around?


Can you put 2 examples here?

1st: how did you set the session data?
2nd: how do you get the data?

Hi Ochetsky,

session data is set on controller level when a user performs a login, which obvoiusly is a server side call. It updates correctly both, the database and the session cookie. Once you are logged in, all "links" are ajax calls, the database value of the session is updated correctly, but the cookie doesn't read correctly (it's still the value when we logged in)

I'm using a little javascript which checks the session cookie value every 15"; (it displays correctly if I call any controller function by typing in the url!)

Accessing the same pages without ajax after logged, directly, does work?

Yes, all works, but the session cookie update at a ajax call

Im pretty confused with your thread, but looking for "session ajax" found this that maybe can help: http://ellislab.com/forums/viewthread/176665/

I've to reformulate my thread, sorry: I've just done a further test and the session cookie actually updates correctly as well. I'm having trouble to read it (all 15'') with my client side script.

I guess you make a ajax request to check the session every 15s.

When you try to get the content the session is erased?
Or, you don't know how to make this JS code?

Hi Ochetski, thanks for your time

what I want to do is to check if a user has been inactive for x seconds. In case of inactivity I show a warning dialog box, which will log out the user in case he is not responding.

what I have is an ajax rich application and CI framework. After logging into the aplication part of the website I'm loading only one view. In this view I have a javascript which checks every x-seconds how the value of the session cookie is. And there I have my problems. Maybe I'm checking the wrong way?

I use:


which should write the cookie value into a div with the id 'txt2'

Looks like you are requesting it just like must be. Are you setting last_activity something like this way bellow?

$sess_data = array(
    'last_activity' => '123123123'

Theme © iAndrew 2016 - Forum software by © MyBB