Another way to do this is to create a session_id field in your user table and use it to store the current user session ID after logging in.
On each page, if session_id does not match the current session_id, delete all session data and redirect them to the login page, as this should be old session data or a parallel session.
Note. After verifying that the session in the user table is the current session, when restoring the session identifier, also remember to update the session_id field in the user table or log out of the system every time the session regenerates the user.
source share