PHP cookie problem - www or without www

后端 未结 4 1018
温柔的废话
温柔的废话 2020-11-29 10:02

Why is it that if I create a cookie on www.example.com and check it on example.com, the cookie doesn\'t exist there? I am planning to just use .htaccess redirec

4条回答
  •  再見小時候
    2020-11-29 10:43

    because php translates www.mydomain.com differently from mydomain.com. If the domains are not 100% identical the cookie wont match.

    And I'm sure the browser also looks for 100% match of the domain name before allowing servers to overwrite them.

    Just use .htaccess to redirect. It's the only SURE way to tackle this in all browsers.

提交回复
热议问题