Forum Moderators: coopster

Message Too Old, No Replies

Cookies - Logging out

         

woldie

8:36 am on May 4, 2004 (gmt 0)

10+ Year Member



Hello,

Just wondering if there is anyway of logging out using cookies, perhaps destroy a cookie, then redirect to the login page?

An example would be if the user clicked on the 'logout' link, then it would do the processing, and redirect to the login page.

Thanks again

:o)

liketoseeyoutry

8:51 am on May 4, 2004 (gmt 0)

10+ Year Member



I usally set the logout script on my login page, for instance ...

login.php?logout=true

This way they end up at the login scren regardless :)

As for a cookie, just set it to expire last year:

time()-60*60*24*365

StupidScript

8:48 pm on May 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You may also clear out a cookie by setting its values to empty strings. For example:

Setting the cookie:
setcookie("cookiename", "cookie value", $expdate);

Clearing the cookie:
setcookie("cookiename", "", $expdate);

This will "erase" the value of the cookie while allowing it to remain persistent. To cause it to become a volatile cookie, eliminated when the browser is closed, also set the $expdate value to "".

StupidScript

6:37 pm on May 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oop. I was incorrect in my last sentence.

Delete the cookie by setting ONLY the value to "". All other parameters must match the cookie to be deleted exactly. Once deleted, it's really deleted, and not persistent or volatile.

Sorry 'bout that.