One of the sites I run has a login page on a different subdomain from the rest of the site. Let’s say, for the sake of discussion, that the login page is here:
I need something on the main site (a poll) to recognize the username, and the only way I can possibly do this with what I have available is to set a cookie on the login page, and retrieve it in the main site.
On the login page, I have tried this:
and this:
Neither of these work. Is there something I’ve forgotten about the way cookies set in one subdomain of foo.com can be readable in another? Or a dumb mistake? Or (uh oh) can it just not be done with the situation I’ve got here?
And no, I can’t do this with server-side scripting in this case…
Nope, that’s not quite it… tried that and it’s still not going through. There must be a way as cookies from all over the .foo domain are showing up… so I guess best bet is to take a look at some of these pages and see what they’re doing differently. Will post what I find out.
Sorry to take so long to try this and get back on it… was forced to back-burner this for a few days.
You could perhaps just carry the username over via a query string to your desired url, and then if that query string exists set a cookie in the next domain.
For example, you could set the cookie username on the register.foo.com domain, and within any page in the register domain or any other *.foo.com domain, you could get the cookie, and append it to the links URLS. eg