I am having trouble saying if a variable in the session is not set then redirect back to the login page any help would be great thank you <?php session_start(); if(!isset($_SESSION['username'])) { header("Location: login.php"); } ?> Code (markup): This doesn't work any thoughts?
I don't see why your code shouldn't work :/ try print_r($_SESSION) on the session, to check if its been set or not..
This is the error that I get: Warning: Cannot modify header information - headers already sent by (output started at /home/mofiki/public_html/testsite/header.php:3) in /home/mofiki/public_html/testsite/header.php on line 6
Ah, the reason its not working is because headers have to be declared before any other content is echoed out or something.. try putting it at the top of the script & including header.php and stuff after
Got it thank you very much for your quick replies it works great now .... the little issues are always the most annoying