CodeIgniter Forums

Full Version: Any way to force sessions to *not* update on certain AJAX requests?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

I'm a fairly experienced CI dev but I'm having trouble finding a good solution for this.

Essentially, I'm trying to implement "idle logout" (session expiration) detection. I'd like to be able to periodically make an AJAX call to check if the current session entry still contains credentials but by making these AJAX calls, the session is updated automatically to extend its validity (indefinitely!).

Has anyone found a way to do this?

Cheers!
Thanks InsiteFX, but I don't think that's quite the problem. Unless I'm misunderstanding? It's not that AJAX requests are blocking/interfering, it's that I'd like to skip the auto-update of sessions on specific AJAX requests.

Please feel free to correct me if I've missed the point you were making.
The only other thing that CI has for Ajax is this:

is_ajax_request()

You may need to extend the library to suit your needs.
Sadly I think you're right. I was hoping for a less arduous solution but I guess extending the Session Library is the only option.

Cheers anyway!
@InsiteFX ...

You're doing it yet again.
You see "Session" and just paste the link to something else mentioning "session".
This doesn't help.

@twistedpixel

You can put a counter in sync with the session cookie.
(01-03-2017, 06:51 AM)Narf Wrote: [ -> ]@InsiteFX ...

You're doing it yet again.
You see "Session" and just paste the link to something else mentioning "session".
This doesn't help.

@twistedpixel

You can put a counter in sync with the session cookie.

Sorry, for some reason I didn't get a notification of a reply here. Actually Narf, that's exactly what I ended up doing (as the second half of the issue you gave me advice on earlier). Works beautifully.