Ell20 Posted September 1, 2008 Share Posted September 1, 2008 Hi, I have the code below, which used to work fine, however I have just changed hosts and now I am getting 2 errors: <?php if (isset($_SESSION['admin'])) { header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "index.php"); ob_end_clean(); exit(); } else { /* If user is logged in */ $_SESSION = array(); session_destroy(); setcookie (session_name(), '', time()-300, '/', '', 0); } ?> Errors: Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in /home/prioryfi/public_html/logout.php on line 11 Warning: Cannot modify header information - headers already sent by (output started at /home/prioryfi/public_html/logout.php:11) in /home/prioryfi/public_html/logout.php on line 12 Appreciate any help Link to comment https://forums.phpfreaks.com/topic/122281-solved-logout-help/ Share on other sites More sharing options...
ohdang888 Posted September 1, 2008 Share Posted September 1, 2008 you have to have: <?php session_start(); at the top of the page Link to comment https://forums.phpfreaks.com/topic/122281-solved-logout-help/#findComment-631417 Share on other sites More sharing options...
Ell20 Posted September 1, 2008 Author Share Posted September 1, 2008 Thanks for help. There are no errors now but it dosent appear to do anything now, any ideas? Cheers Link to comment https://forums.phpfreaks.com/topic/122281-solved-logout-help/#findComment-631422 Share on other sites More sharing options...
ohdang888 Posted September 1, 2008 Share Posted September 1, 2008 nothing amazing is supposed to happen. It simply destroys the session. Add a "echo 'session deleted!'" cluase Link to comment https://forums.phpfreaks.com/topic/122281-solved-logout-help/#findComment-631438 Share on other sites More sharing options...
Ell20 Posted September 1, 2008 Author Share Posted September 1, 2008 Yeah but I mean it dosent even navigate to the logout.php page now which is just supposed to display "You have successfully logged out". Cheers Link to comment https://forums.phpfreaks.com/topic/122281-solved-logout-help/#findComment-631443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.