User’s Inactivity Check and Logout in PHP

User’s Inactivity Check and Logout in PHP

It is an essential professional approach to implement all necessary checks while developing a web based application. Sometimes it is necessary to check user’s inactivity on application because may be user forget to log out or their might be some other reasons too for his inactivity for example cialis canada. So you should have to check if user is inactive for certain period of time, you can log him out and destroy session. Your this approach build user’s trust in your development skills and definitely he will feel secure while using your website or application. So here is a quick way to check user’s inactivity and then log him out and destroy application.

First of all we have to add a single line of code in our login page to add the time of login in session.

Then add following code in every page of your application to check user’s inactivity.

What will this code do?

First it take time from session that we have stored recently in above line, then it will take current time and subtract it from current time. If  the result is greater than 30 minutes (you can change as your wish) it will log out the user and redirect him to our login page and if the result is less than 30 minutes it will store new time in session that is our current time.

User’s Inactivity Check and Logout in PHP

Download above code.

4 Comments

  1. schorsch December 7, 2015
  2. Abdullah Majid December 8, 2015
  3. schorsch December 8, 2015
  4. Mohammed Rishad January 31, 2016

Leave a Reply