views:

37

answers:

1

The project is multiple modules, each of them is deployed to a separate webserver. All of them on the same mainframe. (same IP address)

I have a main menu where I login and then list all the available modules on all servers. From here I can click and go to any of them modules.

I send cookies in the response (when logging in, say Server A), then on Server B (one of the modules) when I want to go back to the main menu, I check the cookies to see if the user is logged in.

The problem is, Server B isn't seeing cookies generated by Server A. So each time I return to main menu, the user will be logged out.

Is there anyway to store cookies to be used by multiple virtual webservers (on same IP) or any other idea?

+2  A: 

If you set the domain-name in the cookie with the correct value, it should work:

i.E. Domainname in cookie: ".host.com"

The cookie will be sent to following hosts: "server1.host.com", "server2.host.com" ....

spookycoder
Domain name isn't set, path is set to "/". And since all applications are deployed to the same physical machine I suppose the root path should work, no?
medopal
If you do not set the domain for the cookie it will be set with an default value, if I remember correctly the full hostname. By default, cookies are only returned to the server that sent them.You can also set a path, which is an additional criteria for the browser to decide if he has to send a cookie or not.i.e. Cookies for domain.com/images and domain.com/files are different - the domain is equal, but the path is different.
spookycoder