PHP-session_set_cookie_params(),生命周期无效 [英] PHP - session_set_cookie_params(), lifetime doesn't work
本文介绍了PHP-session_set_cookie_params(),生命周期无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
首先,我知道很多问题就像我的,但我真的不知道自己在做什么错...
As first, I know a lot questions are like mine, but I really don't know what I'm doing wrong...
您可能已经猜到了,我有一个涉及会话的PHP脚本. 除了设置会话的有效期外,其他所有内容都像魅力一样.
As you might've guessed, I've a PHP script involving sessions. Everything works like a charm, except setting the lifetime of my session.
我想使会话保持活动状态两周,但是我的(Chrome)浏览器说它在浏览会话后设置为xpire(确实如此).我的PHP脚本:
I want to keep the session active for two weeks, but instead my (Chrome) browser says it's set to xpire after the browsing session (and it does). My PHP script:
session_name('DSWLogin');
// Naming the session
session_set_cookie_params(2*7*24*60*60);
// Making the cookie live for 2 weeks
session_start();
// Starting the session
这真的行不通.
预先感谢
以赛亚
推荐答案
将代码重写为
session_start();
setcookie(session_name('DSWLogin'),session_id(),time()+2*7*24*60*60);
这篇关于PHP-session_set_cookie_params(),生命周期无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文