setMaxAge的值为0和负值之间的差异 [英] Difference between 0 and negative value for setMaxAge for Cookie

查看:1909
本文介绍了setMaxAge的值为0和负值之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自setMaxAge(int)的Cookie文件:
http://docs.oracle.com/javaee/1.3/api/javax/servlet/http/Cookie.html#setMaxAge(int)
int = 0和int = -ve?它说0删除cookie。 -ve值表示不存储cookie。

From cookie docs for setMaxAge(int): http://docs.oracle.com/javaee/1.3/api/javax/servlet/http/Cookie.html#setMaxAge(int) Is there any difference between int = 0 and int = -ve? It says 0 deletes cookie. -ve value means cookie is not stored. Does that mean 0 deletes only from current browser session?

推荐答案

我建议你从浏览器的角度去阅读cookies。这很有趣。请注意,'max-age'是'expires'的较新版本,某些浏览器可能不支持。 (例如,IE6,IE7和IE8不支持max-age。)

I suggest you go read about cookies from a browser perspective. It's very interesting. Note that 'max-age' is the newer version of 'expires' and some browsers may not support it. (For example, IE6, IE7, and IE8 don't support max-age.)

0表示立即删除cookie。

0 means delete the cookie right now.

negative表示保留cookie一段时间。我怀疑范围有些浏览器特定,但它不会保留cookie跨关闭和重新打开浏览器。

negative means preserve the cookie for a while. I suspect the scope is somewhat browser specific but it will not preserve the cookie across closing and reopening the browser.

这篇关于setMaxAge的值为0和负值之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆