Page 1 of 1

Logging out?

Posted: Wed Feb 06, 2008 8:27 am
by spacebiscuit
Hi guys,

I have written a small admin system for a courier firm and the client would like a "log out" button.

I use some session variables, is there a standard procedure/function/code that will achive this.

Any feedback would be appreciated.

Thanks,

Rob.

P.S. New look to forum looks fantastic!

Re: Logging out?

Posted: Wed Feb 06, 2008 8:43 am
by Rovas
Use

Code: Select all

 
 
if ($_POST['logout']){session_destroy();}
//where logout is the name of the button or you could use
session_unregister if they logout by mistake and they want login more quickly 
 

Re: Logging out?

Posted: Wed Feb 06, 2008 11:36 am
by Christopher
Or something like:

Code: Select all

if ($_POST['logout']){
     session_start();
     $_SESSION['user'] = null;
}
 

Re: Logging out?

Posted: Thu Feb 07, 2008 7:11 am
by spacebiscuit
Thanks guys - that does the job perfectly!

Rob.