34,333
edits
Changes
→Reading a Cookie in PHP
userName = JohnW<br>
</tt>
== Deleting a Cookie ==
Cookies are deleted by calling the ''setcookie()'' function with the cookie name, a ''null'' for the value and an expiration date in the past. Once again the ''time()'' function can be used to calculate an expired date:
<pre>
<?php
setcookie ('userName', '', time() - 4800);
?>
</pre>
Note that if you specified domain and/or path arguments when you created the cookie you must also specify them when you delete the cookie.