Page 1 of 1

sessions are different if url has www. in front

Posted: Sun Jan 22, 2012 10:53 am
by tehhparadox
Hi all,

There's something quite annoying about sessions - that is, I think the sessions are different for http://example.com and http://www.example.com.
If sessions are set in one, it is not set in the other.
This can get very annoying. Is there a way around this?

Re: sessions are different if url has www. in front

Posted: Mon Jan 23, 2012 7:55 am
by Tiancris
Yep, you're right. Same thing happened to me and I've solved adding a redirect from http://domain to http://www.domain.
This way you ensure that the site is navigated always in the same url.

I made this redirections using cPanel, and the result is something like this (htaccess file):
[text]RewriteCond %{HTTP_HOST} ^blablabla.com.ar$
RewriteRule ^(.*)$ "http\:\/\/www\.blablabla\.com\.ar\/$1" [R=301,L][/text]

And works in all this cases:
[text]http://blablabla.com.ar =====> http://www.blablabla.com.ar
http://blablabla.com.ar/item.php =====> http://www.blablabla.com.ar/item.php
http://blablabla.com.ar/item.php?id=15 =====> http://www.blablabla.com.ar/item.php?id=15[/text]