Jump to content



  • Please log in to reply
1 reply to this topic

#1 sprinkles

  • Members
  • PipPip
  • Member
  • 17 posts

Posted 04 July 2006 - 12:13 AM

I have a problem with sessions.
All the links on my site are prefixed with www.
I've just implemented a registration system, but I'm having a problem with sessions.
If the user visits the site with the www. prefix, the sessions work fine and the user stays logged in, however if the user omits the www. from the address, the user gets logged out when clicking a link.

How can I either solve this, or forward all users to www.?

#2 micah1701

  • Members
  • PipPipPip
  • Advanced Member
  • 613 posts
  • LocationEllington, CT USA

Posted 04 July 2006 - 01:56 AM

I think it would be better for your site if you just took out the absolute paths for your links.
what if you move to a new domain name someday, or add a second domain name? change it now while you can.  some programs, like dreamweaver, let you do a find and replace for your entire site in one quick command.

otherwise you put this snippet of code on the top of every page

if($_SERVER['HTTP_HOST'] != "www.yourDomainName.com"){
header("Location: http://www.yourDomainName.com".$_SERVER['PHP_SELF']);

"Confidence in the face of risk."

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users