php cookie的生命周期,PHP设置cookie生存期

我有这个功能来启动安全会话:

function sec_session_start() {

$session_name = 'sec_session_id'; // Set a custom session name

$secure = false; // Set to true if using https.

$httponly = true; // This stops javascript being able to access the session id.

ini_set('session.use_only_cookies', 1); // Forces sessions to only use cookies.

$cookieParams = session_get_cookie_params(); // Gets current cookies params.

session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly);

session_name($session_name); // Sets the session name to the one set above.

session_start(); // Start the php session

session_regenerate_id(true); // regenerated the session, delete the old one.

}

当用户离开我的应用程序或关闭浏览器时,如何设置Cookie到期?基本上,每次用户访问我的应用时,他们都需要再次登录.

解决方法:

标签:php,cookies,session

来源: https://codeday.me/bug/20190530/1182112.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值