header function not working in php after setting session


so i have creted this php where if session is set do this and if it isn't set than go to another php so my code goes like this

if(isset($_SESSION['id']) && !empty($_SESSION['id']))
        $query="select email from register where id='$id'";

else {header('location: best.php');}

even if i opened this page directly without setting session i am still able to visit and doesn't get redireccted to best.php page how to deall with this problem

People are also looking for solutions to the problem: How to extend PHP with C++?


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.