Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

session_destroy(); 1

Status
Not open for further replies.

TheConeHead

Programmer
Aug 14, 2002
2,106
US
i think I am creating a session via:

Code:
$HTTP_SESSION_VARS['access'] = 'value';
$HTTP_SESSION_VARS['id'] = 'value';

I am trying to do a 'logout' feature with:

Code:
unset($HTTP_SESSION_VARS['access']);
unset($HTTP_SESSION_VARS['id']);
session_destroy();

but I am getting the folowing error:

Warning: session_destroy(): Trying to destroy uninitialized session in .... on line 4

and it is not unsetting the session vars. Any ideas?

thanks


[conehead]
 
Please be aware that HTTP_SESSION_VARS is deprecated since version 4.1.0
If you have a newer version of PHP you can not only save a lot of typing but also be up-to-date with the current valid $_SESSION array.
Look what the PHP manual has to say:
session_destroy() destroys all of the data associated with the current session. It does not unset any of the global variables associated with the session, or unset the session cookie.

In order to kill the session altogether, like to log the user out, the session id must also be unset. If a cookie is used to propagate the session id (default behavior), then the session cookie must be deleted. setcookie() may be used for that.

The PHP manual is a great resource and should be consulted before asking questions in this forum. ;)
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top