PHP/Cookie

PHP/Cookie

Posted by: mygsx
Posted on: 2004-03-19 11:53:00

i'm using PHP throughout my pages.. I can create a cookie, but for some reason it won't let me delete them.

I'm using this for a login/logout situation..

here is some of my code:

setcookie("AcctInfo[username]", $username, time()+60*3, "/directory/", ".mydomain.com");

setcookie("AcctInfo[password]", $password, time()+60*3, "/directory/", ".mydomain.com");

The above code sets the cookie fine and it expires it if you stay logged on too long. (I changed the domain and folders for security reasons).

Then when I try to delete the cookie it doesn't work. I tried the following below:

setcookie("AcctInfo");
or
setcookie("AcctInfo['username']");

Thanks in advance for your help.



www.iboostdaily.com

Re: PHP/Cookie

Posted by: chell
Posted on: 2004-03-19 20:34:00

You need to include all of the information you put into your cookie when you initially set it. So if your cookie were set using:
setcookie("AcctInfo[username]", "$username", time+60, "/directory/", ".mydomain.com");

delete it using:

setcookie("AcctInfo[username]", "", time-60, "/directory/", ".mydomain.com");

At least, the above works for my pages.

~Michelle

Re: PHP/Cookie

Posted by: mygsx
Posted on: 2004-03-19 21:09:00

oh ok, thanks.. i'll give it a shot to see if it works


edit: it works!!!
Edited by mygsx on 03/19/04 11:09 PM (server time).

Tags: password passwordmydomaindeletefoldersreasondomainhelp