PHP question
I set a cookie such as:
<?php
setcookie("site_user", $Name, time() + 14000, "/");
setcookie("site_pass", $Password, time() + 140000, "/");
?>
I then present all of the content. Then I must give them an option of logging out. At that time I need the cookie to be erased/deleted/overwritten.
I have tried erasing the value and setting the time to negative.
------------------
Jason VandeBoom
http://www.mconet.com
Jason VandeBoom
http://www.mconet.com
Anonymous posted this at 21:39 — 15th April 2000.
They have: 5,633 posts
Joined: Jan 1970
A couple of things to realize about cookies which should answer your question:
1) They must be processed before any headers
2) They are taken care of in reverse order - thus, the last cookie listed will be the first to be taken care of.
So, I would recommend do the following on your "logout" page:
<?php
setcookie("site_user", "", time() + 14000, "/");
?>
That would make the cookie blank. I don't know if making it blank will do it or not - I am not sure if there is a way to delete a cookie or not.
Anyway, hope that helps out at least a little bit.
------------------
TWF Administrator
Dynamic Internet Solutions : Windows NT and UNIX Hosting & Dedicated Servers
Patrick Davis posted this at 00:51 — 17th April 2000.
They have: 30 posts
Joined: Apr 2000
I do something like this
<?
$logouttime=time()-9999;
//sets time to a time already passed, thus deleting the cookie
setcookie("Cookiename", "valuedoesn'tmatter", $logouttime, "/");
//cookie is now gone
?>
------------------
OMG It's Furious George!!!
OMG It's Furious George!!!
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.