Crew-Portal Posted November 11, 2007 Share Posted November 11, 2007 How in the world do I do something like... A user visits a page, after they finish with that page (By leavin to another location) It starts a timer that wont allow them to reaccess the page for 10 whole long boring minutes. It has to be with sessions but it cant conflict with any of the previous sessions set! Can anyone help?!?! And dont send me to php.net please, because I have read the stuff thier and I dont understand how it works! Quote Link to comment Share on other sites More sharing options...
trq Posted November 11, 2007 Share Posted November 11, 2007 The only real way of doing this is to set a timestamp (last_active) within a cookie and check against this. However, the cookie can only be set when the user requests a page. trying to set a cookie when a user leaves will be alot more difficult. You may be able to do something using Ajax, but really, and method you find will be pretty unreliable. Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 11, 2007 Share Posted November 11, 2007 You can't really keep someone off like that. Sessions cookies can be easily deleted. Maybe a temporary ip ban. But that can be unreliable. You can try sessions but it won't be a sure fire way to keep anyone away. <?php session_start(); $tstamp = time(); $expires = $tstamp + 600;//time stamp + 600 seconds (10 mins) if(!isset($_SESSION['expiry']) ) { $_SESSION['expiry'] = $expires; } else { $timeleft = $_SESSION['expiry'] - $tstamp; if($timeleft > 0) { exit('You can not access this site for another '.$timeleft.' seconds'); } else { $_SESSION['expiry'] = $expires; } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.