Jump to content

Archived

This topic is now archived and is closed to further replies.

sprinkles

Sessions

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.?

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.