bryanptcs Posted January 12, 2007 Share Posted January 12, 2007 Here is the code for my logout link:[code]<a href="logout.php">Logout</a>[/code]Here is logout.php:[code]<?phpheader('http://www.giftfromgodcomputerfoundation.org'); session_destroy(); ?>[/code]What i need it to do is logout the user and return them to the main page....I get the following error:Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in /home/giftfrom/public_html/staff/logout.php on line 5 Link to comment https://forums.phpfreaks.com/topic/33940-how-do-i-logout-and-kill-the-session/ Share on other sites More sharing options...
taith Posted January 12, 2007 Share Posted January 12, 2007 easier way[code]<?session_start();$_SESSION=array();header('http://www.giftfromgodcomputerfoundation.org');exit;?>[/code]fyi: sessions must be started before its destroyed :-) Link to comment https://forums.phpfreaks.com/topic/33940-how-do-i-logout-and-kill-the-session/#findComment-159357 Share on other sites More sharing options...
bryanptcs Posted January 12, 2007 Author Share Posted January 12, 2007 I also realized that it should have been...header("Location: url");instead of header('url');Thanks for you help. Link to comment https://forums.phpfreaks.com/topic/33940-how-do-i-logout-and-kill-the-session/#findComment-159361 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.