Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share one single cookie through subdomains

I have a blogs subdomain that works well, however, the signin is detached from all subdomains, and consequently, if a user signs in his cookie is only valid on the non-subdomain pages. How can I set my app to make the cookies be valid throughout all subdomains and normal pages?

I worked through this topic: Share session (cookies) between subdomains in Rails? but unfortunately without success. I even tried that long step by step rack middleware approach but wihtout success.

I am using Rails 3.2.13.

Any help appreciated! :)

like image 736
rails_has_elegance Avatar asked Mar 29 '13 07:03

rails_has_elegance


1 Answers

All I needed to do was to specify the domain when creating the cookie, as commented earlier above.

cookies[:remember_token] = { value: user.remember_token, domain: ".lvh.me" }
like image 110
rails_has_elegance Avatar answered Sep 22 '22 06:09

rails_has_elegance