Cookies on localhost with explicit domain

前端 未结 21 2160
[愿得一人]
[愿得一人] 2020-11-22 04:17

I must be missing some basic thing about cookies. On localhost, when I set a cookie on server side and specify the domain explicitly as localhost (or .localhost). t

21条回答
  •  甜味超标
    2020-11-22 05:02

    None of the answers here worked for me. I fixed it by putting my PHP as the very very first thing in the page.

    Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including and tags as well as any whitespace.

    From http://php.net/manual/en/function.setcookie.php

提交回复
热议问题