Register now and start sharing your code snippets.
-->
How to set a cookie, remove a cookie and get the value of a cookie in PHP
PHP posted 3 months ago by christian
PHP cookie management is a good example of how incredibly badly designed PHP is:
Set a cookie that expires when browser is closed
Note that you most probably want to set the path, which we do here:
1 $value = 0; 2 $expires = 0; 3 setcookie('cookie_name', $value, $expires, '/');
Remove cookie
1 setcookie ('cookie_name', FALSE, time()-10000);
Get cookie value
1 $_COOKIE['cookie_name']