Jump to content

session_end and header() issue


EmperorJazzy

Recommended Posts

Afternoon all,

 

Quick query;

 

On the index.php page I have a hyperlink entitled LOGOUT. This allows the users to log out of their current session.

 

The hyperlink directs to a logout.php page with the following contents:

 

<?php
session_end();
?>
<html>
<head></head>
<body>
<?php
header('Location: index.php');
?>
</body>
</html>

 

Essentially; the code should end the session and redirect the browser back to the main page. Currently, the hyperlink does redirect to the logout.php page, but;

 

- it doesn't return to the index.php page

- if I click the back button, the session is still alive

 

Can anyone assist? Is there a better way of doing this?

 

This isn't something that hasn't been done before, but finding the topic in the forums has been difficult.

 

Thanks in advance.

Link to comment
Share on other sites

What are you using to write your code? I just solved the same issue in one of my scripts. It was caused by a BOM (Byte Order Mark) which is an invisible line of code before the initial <?php. PHP will know it's there and process it, which will cause header errors.

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.