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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to expire the session variable

Status
Not open for further replies.

iffoiffy

Programmer
Feb 24, 2005
67
CA
Hi,

I set the session variable doing the following

$_SESSION['emailaddress'] = $email;

When user log out i want to expire that variable, how can i do that?

thanks
 
Code:
unset($_SESSION['emailaddress']) ;
session_destory() ;

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Typo:
session_destroy() is the correct function.
Another way is to use unset($_SESSION) or set $_SESSION = array();
Either way works by wiping out the content of the session. A file may be still in existence until the garbage collection mechanism cleans it up.
 
I am able to destroy the session variable doing following , but I get this ugly loooking warning. I don't know how to get ride of that.....

<?php
session_start();

unset($_SESSION['wholeseller_grade']) ;
session_destroy() ;

?>


*************
Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in c:\websites\sntradersonline22\sntradersonline.com\logout.php on line 5
 
Just put a conditional on it:
Code:
if ($_SESSION) session_destroy();
# or suppress the warning
@session_destroy();
 
Thanks for your reply,

unset($_SESSION['wholeseller_grade']) ;
if ($_SESSION['wholeseller_grade']) session_destroy();

this works..thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top