Skip to content
Advertisement

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

Advertisement

Answer

I was able to do it using the following code:

Cookie cookie = new Cookie("myCookie", "myValue");
cookie.setMaxAge(60 * 60);
cookie.setDomain(".myserver.com");
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement