如何将会话生存期设置为无限 [英] How to set session lifetime as infinite
本文介绍了如何将会话生存期设置为无限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将会话生存时间设置为无限?有一个设置 session.cookie_lifetime
,但是我找不到为无限生命周期需要设置的值。我尝试了0,但是一旦关闭浏览器,它就会过期。
How can I set session life time as infinite? There is a settings session.cookie_lifetime
, but I couldn't find which value I need to set it for infinite lifetime. I have tried 0 but it will expire once browser closed.
ini_set('session.cookie_lifetime', 0);
推荐答案
也许您可以通过将过期时间设置为a很大的价值? :)
Maybe you can try by setting the expiration time to a very big value? :)
根据我对这个问题的看法,您需要的不仅仅是您在问题中所写的内容,例如:
And according what I red on the subject, you'll need more than the line you wrote in your question, something like this:
//set cookie lifetime for 100 days (60sec * 60mins * 24hours * 100days)
ini_set('session.cookie_lifetime', 60 * 60 * 24 * 100);
ini_set('session.gc_maxlifetime', 60 * 60 * 24 * 100);
//maybe you want to precise the save path as well
ini_set('session.save_path', '/home/yoursite/sessions');
//then start the session
session_start();
祝你好运!
这篇关于如何将会话生存期设置为无限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文