morphboy23 Posted July 30, 2007 Share Posted July 30, 2007 Ok so I'm setting up a cookie for whenever a user logs into my site. Here's what I have: setcookie('bloowoologinemail', $result['email'], time()+259200, '/', '.bloowoo.com'); Now, I thought that since I have '.bloowoo.com' for the domain, this cookie would be loaded at both http://www.bloowoo.com and http://bloowoo.com yet it's not. How can I fix it so that it's the same cookie for both with and without www? Quote Link to comment Share on other sites More sharing options...
btherl Posted July 30, 2007 Share Posted July 30, 2007 This doesn't answer your question, but it may solve your problem. One option is to redirect all requests that hit bloowoo.com to hit www.bloowoo.com instead. Then you don't need to worry about supporting two possible hostnames anywhere in your code. Quote Link to comment Share on other sites More sharing options...
morphboy23 Posted July 30, 2007 Author Share Posted July 30, 2007 How would I do that? Quote Link to comment Share on other sites More sharing options...
btherl Posted July 30, 2007 Share Posted July 30, 2007 You can do this at the top of every script (this can be included in a global configuration file) if ($_SERVER['HTTP_HOST'] === 'bloowoo.com') { $new_url = str_replace('bloowoo.com', 'www.bloowoo.com', $_SERVER['SCRIPT_URI']); header('Location: ' . $new_url); exit(0); } Hopefully that'll work. Different servers sometimes set different variables in $_SERVER, so you might need to adjust it. Quote Link to comment Share on other sites More sharing options...
btherl Posted July 30, 2007 Share Posted July 30, 2007 It can also be done in apache using rewrite rules.. but I'm not clear on the details of doing it that way. Quote Link to comment 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.