3

I'm working on a website where the same instance runs across multiple domains (and not just sub-domains).

Is it possible to create a cookie thats accessible across all of these domains? Similar to the way facebook cookies work from everywhere.

dkarzon
  • 7,868
  • 9
  • 48
  • 61

2 Answers2

7

Only for subdomains in the same root domain - you can use wildcard cookies by just specifying the subdomain. ex. sv1.test.com sv2.test.com all would use test.com

see: http://forums.asp.net/t/369569.aspx/1

For using a single cookie cross root domain - you cannot do this. It breaks the rules of trust - otherwise my app could read your other cookies. What happens in sites that 'seem' to share cookies is there is usually a redirect to that other domain to validate a value and then a redirect back to the other domain. Values can then be posted over, set in hidden form fields or the querystring.

Also see this quasi duplicate post: Sharing cookies across different domains and different applications (classic ASP and ASP.NET)

Community
  • 1
  • 1
Adam Tuliper
  • 29,982
  • 4
  • 53
  • 71
  • ahh, I thought this was the case. Thanks for clearing that up. Looks like Facebook use iframes and redirects for this. – dkarzon Apr 20 '11 at 04:52
0

Could you have .js functions on CommonSite.com that store and retrieve the cookies?

So you might have commonSite.com/CookieMonster.js

Then on :

FirstDomain.com/MyPage.htm you could call commonsite.com/cookiemonster.js's SaveCooke(CookieValue)

Same on SecondDomin.com/OtherPage.htm

mipe34
  • 5,596
  • 3
  • 26
  • 38
Clay Nichols
  • 11,848
  • 30
  • 109
  • 170