$_SESSION
A session is a way to store information (in the form of variables) to be used across multiple pages.
<?php
// this line starts the session and must be present in any page where you need to set or retrieve a session variable
session_start();
// this sets variables in the session
$_SESSION['userid']='123'; //obv it will be dynamic
// this retrieves the value set earlier
echo $_SESSION['userid'];
?>
So you can check on every page if the userid
exist in the database
you can fetch its record.
solved How to tell who is logged in PHP? [closed]