Changes

Jump to: navigation, search

PHP and Cookies - Creating, Reading and Writing

460 bytes added, 15:03, 6 June 2007
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.

Navigation menu