php - header() works with wamp but not on server


So i've finally uploaded my work from wamp to my actual website.

Everything seems to runs completely fine exceptheader();


I have so if you're not logged in and try to access the logout url, it would redirect you to the login page.

if(!isset($_SESSION['loggedin'])){ header("Location: index.php?page=login"); exit();

on my localhost on wamp, it works perfect. Although on my website, it doesn't redirect.

I saw a post about this that recommended to use javascript redirect instead but i feel like it's unnecessary since there must be a way to sort this issue with using php.

RESOLVED: The host had the wrong version running and took 3 days to respond.




Use this replace for it

    echo "<script type='text/javascript'>window.location.href = 'index.php?page=login';</script>";

People are also looking for solutions to the problem: php - Echo results not showing


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.