2

i know maybe it's a repetitive question, but i would like to know if someone has a good idea for leave user session alive when using ajax calls.

I figured out that when i'm logged and i leave the browser open for 1-2 hours, when i launch ajax calls the session is expired.

i'm using the standard:

$config['sess_time_to_update']  = 7200;

i would like to know if someone has the definitive way to keep alive the user session, better without using interval js functions

itsme
  • 48,972
  • 96
  • 224
  • 345
  • 2
    `sess_time_to_update` is how many seconds until the session is regenerated. `sess_expiration` is the number of seconds the session will last. Setting `sess_expiration`to 0 will set the session to never expire. – birderic Sep 22 '11 at 19:47
  • oh sorry wrong line i was meaning expiration = 7200 ... so you suggest to put it to 0? i'm on CI 2.0+ version, does will session expire on browser call also if session expiration is setted to 0 (and expire on close = TRUE)? – itsme Sep 22 '11 at 21:34
  • 3
    7200 seconds = 2 hours, so this makes perfect sense. As birderic said, either disable the expiration by setting it to 0, or increase from the default number of seconds. – Mike S. Sep 22 '11 at 22:26
  • 1
    thanxs guys..My problem is solved reading your conversation..again thanxs. – TheFoxLab Nov 07 '12 at 09:18
  • Should you want to continue to have session expiration, please see agustinrc89 answer via http://stackoverflow.com/questions/7980193/codeigniter-session-bugging-out-with-ajax-calls. – tibc-dev Feb 26 '14 at 19:45

1 Answers1

2

The session time is set in the __construct() so you could just call any method from the session library when you are making the ajax call and it should update your session expiration time. I would probably just set an "ajax_request" item in the session just to call the library and fire the constructor to reset the session expiration time.

Chris Schmitz
  • 8,097
  • 6
  • 31
  • 41
  • uhm but i need js ajax calls everytime for refrshing, if you read on top, user birderic has the right answer as i can see :P thx anyway i voted up ;) – itsme Sep 22 '11 at 22:58