Check PHP session value?

Asked

Viewed 35 times

-4

Hello I have a form creates a user session and password, which creates a session according to the information sent by the form and, in index.php, it checks if the session is "set".


PHP:
if(!isset($_SESSION['senha'])) {
   header("Location: login.php"); 
   exit();
}

This code works super well, but I want it to just check a certain value, for example if the $_SESSION['senha'] is equal to 123, if so, it redirects to login.php, otherwise it continues in index.php.

1 answer

0


To function as you wish, you simply have to validate if a $_SESSION['senha'] this "arrow" and is equal to "123".


PHP:
if(isset($_SESSION['senha']) and $_SESSION['senha'] == '123') {
   header("Location: login.php");
   exit();
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.