PHP Cookies works well on localhost, but it's not working on live server

后端 未结 6 1215
死守一世寂寞
死守一世寂寞 2021-01-21 20:25

Note: This issue is already solved, finally I found that it\'s not cookies problem, the problem is on unserialize() function. The serialized cookie which

6条回答
  •  遥遥无期
    2021-01-21 20:38

    While applying solutions we get forgot the basic of Cookies.

    Cookies are like headers. Like the headers, it should be sent before any output generates. then only it sets successfully. I have struggled a lot for this problem but when i went through the basics this problem got solved quickly.

    this syntax will be enough to solve this problem...

    setcookie(
    'settings',
    serialize($defaultSettings),
    time()+3600*24*30,
    '/'          // this is the path
    );
    

提交回复
热议问题