How to set a cookie in a separate domain in Rails

How can you set a cookie in another domain that calls my site with a javascript call? It works in FF3, but not in IE6.

My server is called from a javascript tag on a separate site and in a domain. The result returns javascript that fills its page with data (this is a widget). I am trying to set a cookie using domain = ". Mydomain.com" and path = "/". It works for Firefox, but does not work in IE. It works fine in IE if I test javascript call from my own domain.

Does anyone know how to set up a cross-domain cookie to work in IE using Rails?

+6
ruby-on-rails cookies cross-domain
source share
1 answer

As long as your server sets a cookie in its own domain or from a subdomain of its domain, this should work

cookies[cookie_name] = { :value => 'a value', :expires => 1.year.from_now, :domain => 'example.com' } 

It will not work for any other domains.

To make this work in IE6, you might need a valid P3P policy header.

Something like this sent as a header should do this:

 headers["p3p"] = 'CP="CAO PSA OUR"' 
+9
source share

All Articles