0

I am going crazy trying to figure out this menial but huge problem. I have read about it, I have tested it, but I can't figure out how to fix it.

I understand that, for whatever reason, there is a difference between "www.website.com" and "website.com" when it comes to sessions and cookies.

All I want to do, is have all sessions and cookies talk to both "versions" of the website...

I have tried manipulating my .htaccess file, I have tried messing with session_set_cookie_params, and I have had no luck whatsoever. Can someone PLEASE help me figure this out...

I had this for my .htaccess file, but its EXTREMELY SLOW because it redirects every page load... Is there a way to put if statements in here so that it only does the redirect if necessary?

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^website\.com$ [NC]
RewriteRule ^(.*)$ http://www.website.com/$1 [R=permanent,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^(.*)$ /profile.php?u=$1 [NC,L]
user2492064
  • 591
  • 1
  • 8
  • 21
  • 1
    Have you checked out the fine manual regarding cookies? And once you've done that and you still are stuck and it is not a duplicate we need to see code. – PeeHaa Jan 30 '14 at 07:50
  • I've been reading for about 24 hours, I'll update with code. – user2492064 Jan 30 '14 at 07:52

2 Answers2

0

If you would accept redirection, then I would suggest editing your htaccess file:

RewriteCond %{HTTP_HOST} !^www.sampledomain.com RewriteRule ^(.*)$ http://www.sampledomain.com/$1 [R=permanent,L]

This would redirect sampledomain.com to www.sampledomain.com

simplecoder
  • 203
  • 2
  • 9
0

You should only use website.com or www.website.com and redirect the one not used, to the one you use. This should help you with the redirection.

Community
  • 1
  • 1
enigma
  • 493
  • 2
  • 5
  • 18