0

Do you use cookies or session to time out or lock out someone from your website if they have used it for 2 hours? I want it to lock and have them wait an hour before them using it again.

I got the idea from this website that had a message pop up and say

"you have used this site for 2 hours, please wait an hour and come back or become a member and get unlimited hours"

3 Answers3

1

Two approaches:

  1. The simple one, in which you set a cookie or session (both use cookies in the end, so it hardly matters) to identify a user. The problem with this is that a user may simply discard his cookies or use a different browser, so this solution will only ever work for rather clueless users. It is probably good enough for your use case.
  2. Go crazy with fuzzy identification of users via neural networks, which may/would allow you to identify users pretty uniquely in a way that would not allow them to "change their identity" easily. This is a really complex solution though and may be overkill or unrealistic for your purposes.
Community
  • 1
  • 1
deceze
  • 510,633
  • 85
  • 743
  • 889
-2

probably this will be helpful to you

  if( !isset($_SESSION['last_access']) || (time() - $_SESSION['last_access']) > 60 )
  $_SESSION['last_access'] = time();

This will update the session every 60s to ensure that the modification date is altered.

amit
  • 1
  • 2
-2

please visit below link to know more details with php code

http://riturajkumar12.blogspot.in/2014/04/expire-session-automatically-after.html

Ritu Raj
  • 1
  • 2