Laravel5 Inactivity idle session logout

In this post, I would like to show how to automatically log out the user after some period of inactivity. Session timeout or Session expire depends on the server configuration so in order to achieve our target we are going to write middleware in the Laravel5. Without making any changes to server configurations we will use last activity time to log out the user.

Open your config/session.php and specify the number of minutes that you wish the session to be allowed to remain idle before it expires.

automatically logout user after some period of inactivity
Create a file called SessionDataCheckMiddleware.php in App\Http\Middleware location and copy past below code.

Now open \app\Http\Kernel.php file, add our custom “SessionDataCheckMiddleware” middleware

That is it.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

Arjun
I am Arjun from Hyderabad (India). I have been working as a software engineer from last 7+ years, and its my passion to learn new things and implement them as a practice. Aside from work, I likes gardening and spending time with pets.
DMCA.com Protection Status