Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Setting Cookie Domain

843842Mar 11 2009 — edited Mar 11 2009
Here was my original problem
We have a website company.com and its sub domain subdomain.company.com, both these have a auto login process for which we use cookies. If a user auto logs into company.com he/she needs to re login to subdomain.company.com as the cookies are not shared.

solution: I added the set domain parameter "company.com" while creating the cookie, now both company.com & subdomain.company.com can share the cookie.

new problem: We have internal testing websites www-t1.company.com, www-t2.company.com and so on and our live website www.company.com, if I create a cookie for company.com domain it would end up being shared by all the testing websites and live website which was undesirable.

new solution: I read the request URL and accordingly create the cookie domains - www-t1.company.com, www-t2.company.com and for the website www.company.com, now the cookies are specifically created for each of the environments.

new problem 2: The browser thinks that www-t1 is a sub domain and prefixes it with a '.' so the new cookies look like .www-t1.company.com, .www-t2.company.com (I didn't get a chance to look at what happens in production as we can't deploy there yet) and www-t1.subdomain.company.com can't share this cookie.

So my question is, is there anyway I can prevent this either by not allowing the browser to prefix my domain with a '.' or by some other means and hence create cookies under my test website www-t1.company.com and not as a sub domain.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 8 2009
Added on Mar 11 2009
4 comments
1,052 views