0

When using php-login I had the experience to be oftnen kicked out of a session. The app then performs a login with the remeber-me coockie. Which performs well, if it isn't for the user experience: work lost etc...

Read some posts on a seemingly similar problem with CakePHP:

They are speaking about security levels to be adapted, but I have the impression the solutions are not implementable with php-login.

The issue is occurring both in chrome or IE.

The session.gc_maxlifetime is set to the original 1440 (24 min), but sometimes the session even terminates in less than 6 minutes.

Did someone encounter the same problem? Or knows how to solve?


Found the answer here

In fact, the issue is a configuration problem rather than a code problem. Changed the session.cookie_lifetime to be equal to the session.gc_maxlifetime (1440). No idea why these are set differently by default.

Community
  • 1
  • 1
user2992220
  • 1,092
  • 1
  • 12
  • 20

1 Answers1

1

set somewhere at start:

ini_set('session.gc_maxlifetime', 24*60*60);

OR

got to php.ini file and change this value as You wish.

num8er
  • 18,604
  • 3
  • 43
  • 57
  • Actually 'session.gc_maxlifetime' is set to original value of 24 minutes, but session terminates sometimes even after less than 10 minutes, which indicates parhaps another issue. Anyway, I will try with this setting changed, with one reflection : having a session live during even a day of inactivity doesn't seem good practice. – user2992220 Jun 05 '14 at 10:24
  • I do save session in db also I encrypt cookies. I don't see the problem of keeping session alive during 24 hours. In case of Your problem: have you set session regenerate id in your scripts? – num8er Jun 05 '14 at 10:59
  • Will evetually consider to use session regenerate id, but since it only regenerates when session id exists, this changes nothing to the problem, I think. And to give feedback to your suggestions, changed the maxlifetime, but still kicked out after less than 6 minutes. Any other possible causes? – user2992220 Jun 05 '14 at 11:19
  • Found the answer, you set me on the right path, thanks. – user2992220 Jun 05 '14 at 12:42