Forum Discussion
Chris_Miller
Altostratus
Jun 26, 2010Multi-Domain Cookie Issue
Here's my situation...
I have a site, www.sample.com - configured with Akamai. The "origin" points to a VS on my LTM to which I have an iRule that sends users to different pools depending on a cookie value. I want to allow certain users to hit a specific pool but also want them to do so through Akamai. Since access to Akamai is wide open, I need them to hit my "origin" first and if they match my whitelist, I'll set a cookie and redirect them.
My initial assumption was that I'd do something like this:
1. A user hits origin.sample.com/1
2. My iRule inserts a cookie named "x" with the value of whatever is behind the / - in this case, a 1.
3. The iRule redirects them to www.sample.com (which goes through Akamai) and since they have a cookie value of 1, they'd go to the right pool.
Unfortunately, I forgot that the cookie "x" with value of "1" would be for the domain "origin.sample.com" and not "www.sample.com" so this likely wouldn't work.
Can anyone think of a better way to do this? Could I configure an iRule on my origin VS that looks at cookies from a specific domain?
- hoolio
Cirrostratus
Hi Chris, - Chris_Miller
Altostratus
Posted By hoolio on 06/26/2010 02:15 PM - Chris_Miller
Altostratus
Aaron - how would I go about checking to see whether a cookie exists for a different domain? If they have a cookie for www.example.com, I'll need to remove it before inserting my new one... - hoolio
Cirrostratus
You could check the domain on each cookie using a loop of HTTP::cookie domain against a list from HTTP::cookie names. Are you concerned that you might already have a cookie x set by the app? - Chris_Miller
Altostratus
Posted By hoolio on 06/28/2010 08:22 AM - hoolio
Cirrostratus
The HTTP request doesn't include any details for cookies other than the cookie name and value. So you couldn't tell just from the request what domain a cookie was set for. You might be able to set the name or value with a unique string that tells you what VS (or domain) the cookie was set for. - Chris_Miller
Altostratus
Posted By hoolio on 06/28/2010 08:57 AM - hoolio
Cirrostratus
If the domain on the cookie (and all other attributes), the browser should replace the old cookie with the new cookie value. If the domain or other attribute (like path) is different, then the client will store two cookies. The simplest way to check the exact behavior would be to use a browser plugin like HttpFox and test it. - Chris_Miller
Altostratus
Posted By hoolio on 06/28/2010 09:48 AM - hoolio
Cirrostratus
HTTP user agents enforce a domain "firewall" to prevent one site from setting, accessing or modifying cookies from another domain. A subdomain can set cookies for it's own root domain though. So site1.example.com can set cookies for example.com which will be sent by clients to site2.example.com. But as you found, no subdomain on example.com can't set cookies for example2.com or any other domain.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects