在java中的子域之间共享Cookie?

问题描述:

问候所有
i有一些Cookie存储在 http://sub1.myserver.com
和我想要要在 http://myserver.com
中查看这些内容,您可以如何操作?

greetings all i have some cookies stored in http://sub1.myserver.com and i want to be able to see them in http://myserver.com any ideas how to do that ?

我可以使用下面的代码:

I was able to do it using the following code:

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