Php and Mysql Phrasebook (9780133040333) by Wenz Christian

Php and Mysql Phrasebook (9780133040333) by Wenz Christian

Author:Wenz, Christian
Language: eng
Format: epub
Publisher: Prentice Hall
Published: 2013-10-14T16:00:00+00:00


Deleting a Cookie

Click here to view code image

setcookie('version', '', time() – 10*365*24*60*60);

Click here to view code image

<?php

setcookie('version', '', time() – 10*365*24*60*60);

?>

Tried to delete cookie.

Deleting a Cookie (deletecookie.php)

An intuitive way to delete a cookie is to set its value to an empty string. However, the cookie is still there, albeit without a value. A better way is to additionally send a cookie with the same name again, but provide an expiry date that is in the past. Again, incorrect local time settings have to be taken into account, so use a really small expiry date (for instance, ten years before today). This listing implements this and deletes the version cookie that has been sent by the previous listings. Here, both methods are combined: The cookie value is set to an empty string, and the expiry date is in the past. Figure 6.4 shows the result: The browser tries to delete the cookie by setting the expiry date to the current time; so, in the next second, it is gone.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.