Delete cookie from browser?

后端 未结 6 1675
野的像风
野的像风 2021-02-19 04:03

Is there any way of instructing a web browser to completely delete one\'s cookie set with PHP?

I do not want to expiry it or wait for the brows

6条回答
  •  难免孤独
    2021-02-19 04:20

    I think that you have to use combined approach:

    • set expiration way back in the past (as suggested by Chacha102)
    • use JavaScriptto delete entries from document.cookie DOM object (as suggested by andres descalzo)

    There are 2 good reasons for going with mixed approach:

    • JavaScript can be disabled in the browser
    • not all cookies are visible in document.cookie Some modern browsers are supporting httponly flag for cookies. PHP has support for httponly cookies, see http://www.php.net/setcookie

提交回复
热议问题