Search code examples
phpcookiessetcookieunset

unset($_COOKIE['name']) vs setcookie in PHP$_


I want to know that what is difference between expiring cookies using setcookie with past datetime and using unset($_COOKIE) ? Where the difference is?


Solution

  • An associative array of variables passed to the current script via HTTP Cookies.

    Source.

    Therefore, unset()ing a member shouldn't affect the actual cookies.

    You should always set a date time that has passed to remove cookies.