[Chicago-talk] Reading cookies in wrong domain with raw_fetch

Jim Jacobus jjacobus at ponyx.com
Mon Dec 13 11:19:06 PST 2010


I ran into a problem using raw_fetch CGI::Cookie; which I'm not sure
how to resolve.

I have a few forms on my website which uses cookies to preserve user
items like name, address, etc. These are stored in cookies on their
browser. As you all know one attribute of cookies is the domain name.
I've run into a problem when reading and storing cookies because the
domain is different if the user uses an url of
"http://www.mydomian.com" or "http://mydomain.com" I ended up with
duplicate cookie names with different information since the domain
names were different. If I force the cookie to be written with the
domain ".mydomain.com", it's not read if they link using
"http://mydomain.com". If I hard code the cookie domain to be
"mydomain.com", I can't read if they link using
"http://www.mydomain.com". Is there a way raw_fetch can read the
"other" domain's cookies? The only solution I've been able to come up
with is creating/updating two cookies with different domains (which is
just stupid).

JJ


More information about the Chicago-talk mailing list