Logging out?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Logging out?

Post 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!
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Re: Logging out?

Post 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 
 
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Logging out?

Post by Christopher »

Or something like:

Code: Select all

if ($_POST['logout']){
     session_start();
     $_SESSION['user'] = null;
}
 
(#10850)
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Logging out?

Post by spacebiscuit »

Thanks guys - that does the job perfectly!

Rob.
Post Reply