Reading a domain cookie from a subdomain with Rails

To save some Google Analytics data, I would like to access the GA domain cookie "__utmz" ( domain=.example.com) from my www ( domain=www.example.com) subdomain . Can I read this domain cookie from a subdomain? If so, how can I do this with Rails?

cookies[:__utmz]doesn't seem to work with all browsers.

I know that I can configure my application by setting the cookie domain to ".example.com" in my production.rb ( config.action_controller.session = { :domain => ".example.com" }), but I would prefer (because I do not need my www-subdomain cookie for sharing between all sub-regions).

Hope my question is clear enough ...

Thanks in advance for your help (and sorry for possible errors in my language ...)

+3
source share
1 answer

The only way to allow the application on subdomain.example.com to read a cookie from www.example.com will be for www.example.com to set the example.com top-level cookie.

This would allow subdomain.example.com to read it, but it would also allow every other example.com subdomain to see this - that you said you did not want to.

: cookie . cookie , . , cookie example.com , - subdomain.example.com, BOTH example.com subdomain.example.com.

TL; DR

cookie , , cookie (, ). Google Analytics, .

+1

Source: https://habr.com/ru/post/1761593/


All Articles