mardi 23 novembre 2021

php if statement and redirection

I (php n00b) am doing

<?php if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true): ?>
<!doctype html>
<!--- html and more php here -->
<?php else: ?><?php header("Location: loginForm.php"); ?><?php endif; ?>

to redirect the viewer to the login page if he is not yet loggedin. I think i make sure to have loggedin set correctly in $_SESSION. The problem is that i am always redirected to the loginForm.php even if i should be loggedin.

Aucun commentaire:

Enregistrer un commentaire