怎样把Cookie的生存时间设置为无限长啊,,,,

demo大师粉丝 2004-09-28 08:55:53
怎样把Cookie的生存时间设置为无限长啊,,,,
...全文
215 点赞 收藏 3
写回复
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
demo大师粉丝 2004-09-28
呵呵,,,谢谢两位的回答
回复
xunyiren 2004-09-28
晕,不支持上标,最大为2的31次方,再减去1秒.
回复
xunyiren 2004-09-28
setMaxAge
public void setMaxAge(int expiry)Sets the maximum age of the cookie in seconds.
A positive value indicates that the cookie will expire after that many seconds have passed. Note that the value is the maximum age when the cookie will expire, not the cookie's current age.

A negative value means that the cookie is not stored persistently and will be deleted when the Web browser exits. A zero value causes the cookie to be deleted.

Parameters:
expiry - an integer specifying the maximum age of the cookie in seconds; if negative, means the cookie is not stored; if zero, deletes the cookie

好像不能把Cookie的生存时间设置为无限长,最大为231-1秒.
回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告