Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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'); ?>
Hope it will works for you :
<?php session_destroy(); header("Location: http://www.example.com/"); exit; ?>
Add a comment
Use ob_start(); on top of page.. and ob_clean(); on bottom of page.. then this work fine..
Try below code
session_destroy(); header("Location: http://example.com/myOtherPage.php");
Probably you have ?> <?php statement in your code
?> <?php
A simple soloution is Adding ob_start(); at the top of your code and ob_end(); at bottom
ob_start();
ob_end();
Required, but never shown
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.
Explore related questions
See similar questions with these tags.