rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: "Jan M." <jmfaber@gmail.com>
To: Rack Development <rack-devel@googlegroups.com>
Subject: Cookie on a subdomain can get lost/hidden on IE
Date: Wed, 1 Dec 2010 15:59:30 -0800 (PST)	[thread overview]
Message-ID: <90acafa6-979f-47a1-8a30-53066ba54267@s4g2000yql.googlegroups.com> (raw)


This isn't really a bug in Rack but it is some really unexpected
behaviour that caused a bug in my application that literally cost me
days to figure out so I feel compelled to explain it here in case
someone else goes googling for lost session cookies in Rails on
Internet Explorer (which are handled by rack).

Here is the scenario:
- a user first visits "yoursite.com" and gets a session cookie
- the user then gets redirected to "www.yoursite.com" and gets a
different session cookie since www is a different subdomain
- here is where it gets ugly: as long as they are on the "www'
subdomain rack will now read the session store from "yoursite.com" but
write to the session store for "www.yoursite.com"

I looked into this but according to the RFC the order in which cookies
from subdomains are returned is not defined so rack really can't be
blamed, it just picks the first cookie it gets. The other browsers
only return the cookie for the subdomain instead of both cookies like
IE does.

The mitigation is to either make sure you do the redirect to the "www"
domain before hitting your app so it hasn't had a chance to set a
session cookie, or you can explicitly set the domain in the cookie to
".yoursite.com" (note the leading dot) so one cookie will cover both
domains.

The message I got from users is "I can't log in" from less than 1% of
my users. You can imagine it takes a while before I established what
happened, because it only happens to individuals who somehow typed in
the URL without www and only if they use IE.

                 reply	other threads:[~2010-12-01 23:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://groups.google.com/group/rack-devel

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=90acafa6-979f-47a1-8a30-53066ba54267@s4g2000yql.googlegroups.com \
    --to=rack-devel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).