I know how to delete a cookie but my question is, how do I delete a cookie at the time the user leaves a certain page? As long as the user is still on a profile page, let's say, keep the cookie but as soon as the user leaves the profile page to a different page then delete the cookie so I can reset the cookie to a different value. Can this be done? If so, will you mind show me how?
Thank you,
ljCharlie
How to delete a cookie when a user leaves a page?
Moderator: General Moderators
Many thanks for your response. Okay, let's say I set the cookie at the begining of the page called profile.php. Now when the user browse to the page called login.php, where do I set the expire date, on the begining of the login.php page or at the very end of the profile.php page?
By the way, how do I update the value in the cookie?
ljCharlie
By the way, how do I update the value in the cookie?
ljCharlie
Update the value by overwriting it (set the cookie again).
You'd have to set the expire date at the beginning (before any HTML) of the next page the user hits.
You'd have to set the expire date at the beginning (before any HTML) of the next page the user hits.
Last edited by Grim... on Tue Jun 08, 2004 9:18 am, edited 1 time in total.
At the top, otherwise you get the header-error.
Cookie tutorial#1: http://www.juicystudio.com/tutorial/php/cookies.asp
Cookie tutorial#2: http://www.spoono.com/php/tutorials/tut ... rl=cookies
Cookie tutorial#3: http://www.zend.com/zend/tut/feedback.php
and, lastly:
viewtopic.php?t=11417
Cookie tutorial#1: http://www.juicystudio.com/tutorial/php/cookies.asp
Cookie tutorial#2: http://www.spoono.com/php/tutorials/tut ... rl=cookies
Cookie tutorial#3: http://www.zend.com/zend/tut/feedback.php
and, lastly:
viewtopic.php?t=11417
use javascript to delete the cookie.
eg:
eg:
Code: Select all
<body onunload="document.cookie = 'yourCookieName=yourCookieValue; expires=Sat, 10-Jun-2000 00:00:00 GMT;';">
... Your page ...
</body>