I'd suggest you have a further read on cookies and how they relate to
intricacies of HTTP. It can get a bit tricky ;).
Anyway. The PHP script wouldn't 'delete' the cookie from your computer,
it simply sends a header to your browser stating that the cookie has
expired, and it is then up to the browser to delete that cookie from
_then on after_.
So usually once you have sent a cookie that will expire the current
cookie (read: setting a cookie of the same name, but a past expiry date):
setcookie('mycookie', '', mktime()- 31536000, $cookiepath,
$cookiedomain, $cookiesecure);
You will then need to instruct the browser to refresh the page, by
sending a location header:
//
// Time to refresh!
//
header ('Location: index.php');
Hope this helps,
Grant.
Ralph Freshour wrote:
I wrote a small .php script that creates a cookie on my local PC - I
also wrote one that deletes it.
My question is this: when the cookie has been created and I run the
delete .php script, when it first loads it does not delete the cookie
- I always have to click on the browser refresh button - why doesn't
the script execute on the first execution?
Thanks...