sprinkles Posted July 4, 2006 Share Posted July 4, 2006 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.? Quote Link to comment https://forums.phpfreaks.com/topic/13602-sessions/ Share on other sites More sharing options...
micah1701 Posted July 4, 2006 Share Posted July 4, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/13602-sessions/#findComment-52726 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.