开发者

Sharing Cookies Between Sub Domains in java?

I have some cookies stored in http://sub1.开发者_高级运维myserver.com and I want to be able to see them in http://myserver.com


I was able to do it using the following code:

Cookie cookie = new Cookie("myCookie", "myValue");
cookie.setMaxAge(60 * 60);
cookie.setDomain(".myserver.com");


When you set the cookies from sub1.myserver.com, you must specify a domain of "myserver.com" -- this will instruct the browser to send the cookies to myserver.com and all subdomains.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜