Results 1 to 2 of 2
Thread: Setting domain of cookie
- 07-08-2010, 04:27 AM #1Member
- Join Date
- Jul 2010
- Rep Power
Setting domain of cookie
We have a scenario whereby we have 2 portals of different domains and 1 portal is the leading portal that has a login page where when user logins, submits credentials to the 1st and 2nd portal and sign on simulatenously seamlessly.
This is done by creating a java servlet in the 1st portal that forwards the user details to the 2nd portal. 2nd portal returns the cookie to the servlet which passes it back to the browser. The servlet successfully receives the cookie, but cannot set the domain of it - cookie would disappear - i understand this is natural behaviour to disalllow setting of cookie that is of a different domain than where the servlet resides, is this correct? Can anyone confirm this?
If so, how else can i pass back the cookie to the browser?
- 10-23-2010, 05:29 AM #2Member
- Join Date
- Oct 2010
- Rep Power
I've dealt with this issue before... you have a couple of options for how to handle this.
AFAIK, there are two ways to deal with this problem when you've got a front-end portal handling a session with another back-end server:
If both servers are in the same DNS domain, you can set the cookie domain to the common portion of the DNS names. I.E., if you have portal.company.com and otherserver.company.com, you can set the cookie with domain company.com. This is OK if you don't mind sharing your cookie with every other server inside the company.com domain; the security ramifications of that need to be considered. Obviously, setting a cookie with just a top-level domain like com is a terrible idea (and may not even work; I haven't tried it).
The other setup I've seen is where the users never interact directly with the back-end web server. Instead, the front-end portal acts as a proxy for all requests that go through to that other server. The advantage of this is that the portal gets complete control over the cookies - it can rename them, change the domain, etc. This can take care of any issues you would have setting the cookie in the client's browser.
Hope this helps.
- By OrangeDog in forum Java AppletsReplies: 1Last Post: 04-28-2009, 05:44 AM
- By javanewbie in forum Advanced JavaReplies: 0Last Post: 11-11-2008, 05:03 PM
- By Bettypeng in forum Reviews / AdvertisingReplies: 2Last Post: 05-12-2008, 09:21 AM
- By damounh in forum Java AppletsReplies: 0Last Post: 05-08-2008, 03:41 PM
- By Java Tip in forum Java TipReplies: 0Last Post: 01-25-2008, 08:08 PM