Ok, this is perhaps the dumbest question ever but I cannot figure out why this is happening.

I have simple login that checks your email and pass via the database and then sets a cookie on your system. But I allow multiple users to use the same machine so if that is not the user, they have the option to delete the cookie and relogin.

Here's the problem:

I have the login built ok, and the cookie sets fine but if I try to delete the cookie in the same session via setcookie($cookiename), it doesn't reset it until I close out the browser and open it back up.

Is there a way to avoid having to close out the browser?

    You cannot delete a cookie by closing the browser.. Your thinking of sessions..

    if you had a cookie called name youd delete it like this

    setcookie("name",$HTTP_COOKIE_VARS[name],time()-60);

    Should work.

      This might work as well:

      setcookie("cookiename","",1);

      You have to leave the second argument blank ,and the third one is the UNIX timestamp that have elapsed since 1970 January 1.Setting it to 1 is more than enough to do the job.

        Write a Reply...