Site cookies: what's happening and what can I do about it?
November 18, 2008 8:52 AM Subscribe
Site cookies: what's happening and what can I do about it?
The three variables:
www.sitename.com (A)
www.totallydifferentsite.com/sitename (B)
subdomain.sitename.com (C)
Currently, A holds content and B holds ecommerce portion of the site. C has been set up to point to B.
If my pages physically live on B, what's happening on C when I set a cookie? Of course, it's not working, but I'm not quite sure I understand why. If I visit B, the cookies work, if I visit C, they don't. I have some hunches, but have no idea if they are correct.
And, most important, is there anything I can do about it?
www.sitename.com (A)
www.totallydifferentsite.com/sitename (B)
subdomain.sitename.com (C)
Currently, A holds content and B holds ecommerce portion of the site. C has been set up to point to B.
If my pages physically live on B, what's happening on C when I set a cookie? Of course, it's not working, but I'm not quite sure I understand why. If I visit B, the cookies work, if I visit C, they don't. I have some hunches, but have no idea if they are correct.
And, most important, is there anything I can do about it?
This thread is closed to new comments.
As for C: you can set a cookie that will work across all subdomains for a given domain by setting the domain as ".sitename.com" -- this will not, however work if the user visits "sitename.com" (it will work for "www.sitename.com"). (A lazy but acceptable fix for this one is to set duplicate cookies at "sitename.com" and ".sitename.com", so long as you're careful to keep them in synch).
The workarounds for sharing cookies across domains all boil down to various ways of passing the necessary information between the domains using some mechanism other than cookies... some people get fancy with url redirects; I generally just pass an ID along in the url and use it to retrieve the data behind the scenes.
posted by ook at 9:21 AM on November 18, 2008