I am using the following code to check if the user is logged in and if they are not; then redirect them to the login page.
if(!$user->is_logged_in()){ header('Location: login.php'); }
This exact same method works on my local server but not on the web example. Not sure if it is relevant but I'm using GoDaddy as my webhost.
I have checked the error logs which are showing nothing.
I have used if(!$user->is_logged_in()){ echo('NOT LOGGED IN'); }
to check that $user->is_logged_in()
is working correctly.
To check whether headers had already been sent I have tried using:
if (!headers_sent()) { header('Location: http://www.example.com/'); exit; }
This experiences the same issue, it works on my local but not web host.
This is my first question apologies if I was not thorough enough. If there is any other information you require please let me know.