I have a user session in my website. In login page I do:
//mysqli select
if (password_verify($password, $hash)) {
$_SESSION["user"] = $user;
}
so every page I just check: if(!isset($_SESSION["user"])){die();}
my friend told me that I should record in a session, on login, the password too, like this:
if (password_verify($password, $hash)) {
$_SESSION["user"] = $user;
$_SESSION["pass"] = $pass; //$pass that user type in login
}
and in each page do a select in mysql again with session user and pass do check if login is valid or not.
So my question is, do I need to check password in mysql each page or can I do it just once in login?