Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
307 views
in Technique[技术] by (71.8m points)

php - different session with url's with-www and without-www

I have a interactive web site that has authors. When an author enters the site on www.mysite.com and logs in, the session varible becomes

$_SESSION[loggedid]=true;

and site-theme changes.

But when he enters mysite.com (without www's) even he is logged in, he sees the default theme, can't write etc. I think they are different sessions, am i right? Is it depends on my server or browser or what? How can i make this 2, same sessions or redirect the user's from one to one?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Add this to your .htaccess file:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...