Cookies not working on different pages

后端 未结 9 1645
长发绾君心
长发绾君心 2020-12-03 17:19

Ok I have a cookie set, and I can clearly see it if I go to private data in Firefox... ok so when I echo it on one page in a certain directory it works, (www.example.com/dir

9条回答
  •  春和景丽
    2020-12-03 18:15

    Cookies Must Be Set Before Page Output !!! Since cookies are sent by the script to the browser in the HTTP headers, before your page is sent, they must be set before you even send a single line of HTML or any other page output. The moment you send any sort of output, you are signalling the end of the HTTP headers. When that happens, you can no longer set any cookie. If you try, the setcookie() function will return FALSE, and the cookie will not be sent.

提交回复
热议问题