Remove a cookie

后端 未结 22 1616
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 16:16

When I want to remove a Cookie I try

unset($_COOKIE[\'hello\']);

I see in my cookie browser from firefox that the cookie still exists. How

22条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 16:54

    This is how PHP v7 setcookie() code works when you do:

    
    

    From the output of tcpdump while sniffing on the port 80, the server sends to the client (Browser) the following HTTP headers:

    Set-Cookie: user_id=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0
    Set-Cookie: session=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0
    

    Observing packets in the following requests the Browser no longer sends these cookies in the headers

提交回复
热议问题