Session End

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

Session End

Post by AliasBDI »

I am making a logout page and I need to close a session. I tried using "session_unregister();" but it gives me this error:
Wrong parameter count for session_unregister()
Any ideas why?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

If you're using PHP >= 4.1.0 then don't use session_register/unregister, use $_SESSION.

E.g.

Code: Select all

session_start();
if(!isset($_SESSION['foo'])){
    $_SESSION['foo'] = 'hello';
}
echo $_SESSION['foo'];
And to unset/unregister

Code: Select all

unset($_SESSION['foo']); //to just unset 'foo'
session_destroy(); //unset all session variables

//if you have register_globals On, which you shouldn't have...
$foo = '';
unset($_SESSION['foo']);
User avatar
richie256
Forum Commoner
Posts: 37
Joined: Mon Oct 13, 2003 8:00 pm
Location: Montréal/Canada

Post by richie256 »

I prefer to use this one:

Code: Select all

<?php
session_start(); 
session_destroy(); 
$_SESSION = array(); 

?>
Post Reply