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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.