Jump to content

Logout not re-directing...


INeedAGig

Recommended Posts

Hey guys, me again. A few of you were helping me with my login script, which I did finally get working. I am having one small problem though. Upon clicking the logout link, it does not re-direct back to the login page, it just stays blank. I have pasted my code from my logout.php file for reference. Thanks in advance for your help! :)

 

Logout.php code

<?php
session_start();
session_destroy(); {
header("location: login.php");
}
exit();
?>

Link to comment
https://forums.phpfreaks.com/topic/232333-logout-not-re-directing/
Share on other sites

Okay, I tried your suggestion and changed the code to

 

<?php
session_start();
session_destroy();
header ("location: login.php");
session_close();
?>

 

This results in the following error:

 

Fatal error: Call to undefined function: session_close() in logout.php on line 5

 

Okay, I tried your suggestion and changed the code to

 

<?php
session_start();
session_destroy();
header ("location: login.php");
session_close();
?>

 

This results in the following error:

 

Fatal error: Call to undefined function: session_close() in logout.php on line 5

 

Sorry, I meant session_write_close(). Try it without an exit() or close. If that doesn't work, I'm just being stupid and someone else will point it out :P

You apparently have a blank line before the <?php tag. That is output that is sent to the browser and will produce a header() error.

 

At the risk of being repetitive, someone has previously suggested to you to set error_reporting to E_ALL and display_errors to on so that php will help you when you are developing and debugging your code. You will save a TON of time.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.