0

I am trying to do a simple logout page where it destroys the user session and then redirects them to the home page.... not sure why this isn't working. Here is the whole file.

<?php
session_destroy();
header('location: http://example.com');
?>

4 Answers 4

2

Hope it will works for you :

<?php
session_destroy();
header("Location: http://www.example.com/");
exit;
?>
Sign up to request clarification or add additional context in comments.

Comments

1

Use ob_start(); on top of page.. and ob_clean(); on bottom of page.. then this work fine..

Comments

0

Try below code

session_destroy();
header("Location: http://example.com/myOtherPage.php");

Comments

0

Probably you have ?> <?php statement in your code

A simple soloution is Adding ob_start(); at the top of your code and ob_end(); at bottom

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.