Jump to content

Sessions


sprinkles

Recommended Posts

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.?
Link to comment
Share on other sites

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

[code]if($_SERVER['HTTP_HOST'] != "www.yourDomainName.com"){
header("Location: http://www.yourDomainName.com".$_SERVER['PHP_SELF']);
}[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.