Why are cookies only sent to http://www.example.com and NOT http://example.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/04/06
            8:23 UTC
        
        
        Read the original article
        Hit count: 285
        
I have a PHP login which sets 2 cookies once someone login. The problem is that if you login from http://www.example.com and you go to http://example.com, you will find yourself not logged in. I think that is because the browser only send the cookies to the first syntax.
It is 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); ?>
© Stack Overflow or respective owner