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: (A) (B) (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?
posted by unsigned to Computers & Internet (1 answer total)
Cookies are sandboxed by the domain that the user is visiting; the physical location of the files does not matter at all. So if you set a cookie from domain A, it will work on A only; if you set a cookie from domain B it will work on B only.

As for C: you can set a cookie that will work across all subdomains for a given domain by setting the domain as "" -- this will not, however work if the user visits "" (it will work for ""). (A lazy but acceptable fix for this one is to set duplicate cookies at "" and "", 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

« Older Anyone know anything about Noxer?   |   Measure Twice, Email Once Newer »
This thread is closed to new comments.