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
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

 

Link to comment
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

 

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.