php cookie 默认的时长是多久
2 回答

慕斯王
TA贡献1864条经验 获得超2个赞
没有默认
setcookie('history_id','10000',time()+3600,'/');
意思是,在当前网站域下,保存名称为history_id,值为10000的cookie,3600秒
setcookie('history_id','',-1,'/');这句的意思是,销毁名称为history_id的cookie

有只小跳蛙
TA贡献1824条经验 获得超8个赞
默认是到浏览器关闭,设置一天增加有效期就行了,例如:
<?php
$value = 'something from somewhere';
setcookie("TestCookie", $value);//浏览器关闭
setcookie("TestCookie", $value, time()+3600); //1小时
setcookie("TestCookie", $value, time()+3600*24);//1天
?>
- 2 回答
- 0 关注
- 749 浏览
添加回答
举报
0/150
提交
取消