Closed Thread Icon

Topic awaiting preservation: Deleting Session Cookie Pages that link to <a href="https://ozoneasylum.com/backlink?for=25204" title="Pages that link to Topic awaiting preservation: Deleting Session Cookie" rel="nofollow" >Topic awaiting preservation: Deleting Session Cookie\

 
Author Thread
saurabh
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Mar 2005

posted posted 03-07-2005 11:33

How to delete a cookie set by session() function after a user hits logout or choose to end his session.

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 03-07-2005 11:48

If the session is closed, the session variables die an horrible death.

If the user logs out, you're supposed to direct him/her to a log out page where you session_unset( ).

saurabh
Obsessive-Compulsive (I) Inmate

From:
Insane since: Mar 2005

posted posted 03-07-2005 12:02

I tried doing session_unset() but its not deleting the cookie set by the session_start() and I want to delete the cookie whenever a user logs out

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 03-07-2005 12:07

cookies and sessions variables are 2 different things.
If you want to delete a cookie, set it with an expiration date in the past like that :

code:
setcookie( "TestCookie", "", time()-3600 );



saurabh
Obsessive-Compulsive (I) Inmate

From:
Insane since: Mar 2005

posted posted 03-07-2005 12:14

whenever u start a session a cookie PHPSESSID is set to ur browser.NOw the problem I am facing is:
Whenever I try to login when this cookie is set in the browser I am unable to start a session, and if I delete this cookie using Firefox and then try to login a new session is created and the cookie PHPSESSID is set again in the browser.I am using Windows 2K,IIS,MSSQL and PHP.I tried deleting this cookie by
setcookie("PHPSESSID","") ;
as written in the PHP5 Bible but unable to delete this cookie using this function.

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 03-07-2005 13:19

the sessions variables are assigned to a Session Id, which id is stored in a cookie so that the client "remember" it and can pass it to the server to retrieve its session variables.

Have you tried to delete it with :

code:
setcookie( session_name() ,"",0,"/" );



saurabh
Nervous Wreck (II) Inmate

From: India
Insane since: Mar 2005

posted posted 03-07-2005 16:12

Thanks for the help,It worked out.
Will come back shortly with another querry.

Microsoft Windows
32 bit extensions and a graphical shell for a 16 bit patch to an 8 bit operating system originally coded for a 4 bit microprocessor, written by a 2 bit company that can't stand 1 bit of competition.
-A PHP WebForum

« BackwardsOnwards »

Show Forum Drop Down Menu