PHP: Why Cookies only sent to http://www.xxx.com and NOT http://xxx.com

Posted by Axel on Stack Overflow See other posts from Stack Overflow or by Axel
Published on 2010-03-22T01:51:07Z Indexed on 2010/03/22 2:01 UTC
Read the original article Hit count: 547

Filed under:
|

Hi,

I have a php login which sets 2 cookies once some one login. the problem is that if you login from : http://www.mydomain.com and you go to http://mydomain.com you will find your self not logged in, I think that's because the browser only send the cookies to the first syntax.

It's only one domain, the difference is the www. before the domain name, so how to set cookies to the whole domain whatever there is www. or not ?

<?php setcookie('username',$username,time()+3600); ?>

Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about cookies