开发者

Codeigniter: User session keeps expiring

开发者 https://www.devze.com 2023-02-20 20:18 出处:网络
I\'m using C开发者_运维问答odeIgniter, and I\'m having a small issue with sessions. I\'ve set \'sess_expiration\' in config.php to 0 so that the user session will never expire, yet users -even myself-

I'm using C开发者_运维问答odeIgniter, and I'm having a small issue with sessions. I've set 'sess_expiration' in config.php to 0 so that the user session will never expire, yet users -even myself- are still occasionally kicked out and asked to login again! (i'm storing sessions in the DB btw)

The way I validate a user's session is by basically checking if user_id (which I've previously stored in the session is TRUE or FALSE. If it's FALSE then it asks them to login again.

Any idea what could be forcing sessions to expire?

Appreciate your help :)


If you're making AJAX requests in your app/site I think this may be the issue you are experiencing: https://github.com/EllisLab/CodeIgniter/issues/154

It seems to be a bug in how CI handles AJAX requests updating sessions.


Try setting the session expire to some really large number. Try:

time()+(3600*24*365*5)

or

time()+157680000;

This session should last you 5 years.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号