I have a problem with locking the page with session AND I have to
let it redirect to login.php if not logged in
This is the script I have and I´ve tried many of them and somehow none of them works
<?PHP
include("include/session.php");
?>
<?PHP
if(isset($_SESSION['logged_in'])){
unset($_SESSION['logged_in']);
else
{
header ("location: login.php");
}
?>
<?PHP
if($session->logged_in){
?>
This code did worked at sometime but it didn´t redirect my to the login.php
This is the code on frontpage and every subpage where the page is locked
so makeing attempt to access it should redirect to the login.php
Any suggestions?
Either there are quite a few things wrong with your code, or I misunderstand the question_
if(isset($_SESSION['logged_in'])){ends with an unbalanced bracketunset()the logeed-in status, if you read it from the session?if($session->logged_in)the same asif(isset($_SESSION['logged_in']))?Anyway, what I suggest is
header ("location: login.php");toheader ("Location: login.php");, some browsers might be picky with the caps,
And make absolutely sure, nothing (especially no line breaks or whitespace) are ouptut in
include/session.php