Rails cookie session sharing and "www.example.com" or "example.com" problem
- by Rafael Mueller
When people access my app on www.example.com and log in, they get a cookie. I'm using the cookie option to store session on Rails. Accessing example.com (without the www), they must log in again, because Firefox does not recognize the previous session.
So, what do you think is the best way to avoid this?
I guess I will use a small .htaccess rule (Apache + Passenger) like this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]
Do you guys think that is a good solution?