I got a design where it has a screen lock functionality. Now how can I create a screen lock that will basically make the user partially logout. i.e. his username email address etc still going to be shown on the lock screen, just like windows but he would need to retype his password to get access to the site again. I have spent the whole day searching clue for this without success.
Create a session variable or cookie that flags the user as authenticated beyond the screen lock. You can expire it every 10 minutes or whatever time you need to lock the screen.
PHP runs server side, so it can do nothing to the user’s screen. You can time out the $_SESSION after a set period and force a new log in. You can use javascript to run a timer that logs the user out when it expires, reseting the timer when the user interacts with the page.
I would have a session value such as
$_SESSION[‘screen_locked’] = true
Your check for “is user logged in” needs to look for this so no one can type in a url and load a page. And the login form processing needs to set this to null or false.
The login page can check if logged in but screen locked. If so, show the username,etc with the login form.