我在试着设置cookie的域名。但是它不起作用,我的曲奇在此之后就没有创建了:
javax.servlet.http.Cookie responseCookie =
new Cookie(startpackCookie.getName(),
startpackCookie.getValue());
responseCookie.setMaxAge(startpackCookie.getMaxAge());
responseCookie.setPath(startpackCookie.getPath());
responseCookie.setDomain(startpackCookie.getDomain());
System.out.println("Cookie max age: " +
responseCookie.getMaxAge());
System.out.println("Cookie path: " + responseCookie.getPath());
System.out.println("Cookie domain: " + responseCookie.getDomain());
response.addCookie(responseCookie);输出:
10:28:34,899 INFO [stdout] (http-/127.0.0.1:8080-5) Cookie max age: -1
10:28:34,900 INFO [stdout] (http-/127.0.0.1:8080-5) Cookie path: /
10:28:34,900 INFO [stdout] (http-/127.0.0.1:8080-5) Cookie domain: playground.startpack.ru
10:28:34,901 INFO [stdout] (http-/127.0.0.1:8080-5) Cookie was sended如果我要删除域设置,它将与localhost域一起工作。怎么了?
发布于 2014-03-20 06:41:36
在Sun的网站上,“默认情况下,cookie只返回到保存它们的主机。”
此外,域名以指定域名系统(DNS)区域中的服务器可见的点(".foo.com")开始(例如,www.foo.com,而不是a.b.foo.com)。
https://stackoverflow.com/questions/22525256
复制相似问题