wwedude Posted August 28, 2008 Share Posted August 28, 2008 Is their a way in which I could limit viewing the page, for example after you visit the page, you can't again for 1 day? Thanks for any help! Quote Link to comment https://forums.phpfreaks.com/topic/121739-time-access/ Share on other sites More sharing options...
rhodesa Posted August 28, 2008 Share Posted August 28, 2008 once you distinguish a 'user', you can just log in a database when they visit a page, and then restrict them from doing so again for specific amount of time....that is the easy part the hard part is distinguishing a 'user'. if you have a login/pass set up already, you are good to go. but if it's just anonymous users, there is no full proof way. you can log their IP, but that can be spoofed. you can use a cookie, but those can be disabled/manipulated. ...hope that helps Quote Link to comment https://forums.phpfreaks.com/topic/121739-time-access/#findComment-628021 Share on other sites More sharing options...
.josh Posted August 28, 2008 Share Posted August 28, 2008 Not reliably, unless you force some kind of login system. edit: sorry. basically what ^ said. Quote Link to comment https://forums.phpfreaks.com/topic/121739-time-access/#findComment-628022 Share on other sites More sharing options...
kratsg Posted August 28, 2008 Share Posted August 28, 2008 The following methods do work (and downfalls explained): 1.) IP Logging 2.) Cookies 3.) Sessions 1.) An IP can be changed by many methods (such as proxies) and it also can be random based on their choice of web browser (such as AOL for instance). 2.) Cookies can be disabled, deleted, and possibly manipulated (for those skilled in cookie manipulation) 3.) Sessions time-out when the browser closes (unless you otherwise define it, but then it becomes almost identical to a cookie) Quote Link to comment https://forums.phpfreaks.com/topic/121739-time-access/#findComment-628028 Share on other sites More sharing options...
wwedude Posted August 28, 2008 Author Share Posted August 28, 2008 once you distinguish a 'user', you can just log in a database when they visit a page, and then restrict them from doing so again for specific amount of time....that is the easy part the hard part is distinguishing a 'user'. if you have a login/pass set up already, you are good to go. but if it's just anonymous users, there is no full proof way. you can log their IP, but that can be spoofed. you can use a cookie, but those can be disabled/manipulated. ...hope that helps I do have a user system, and I will be requiring login to access this page. So what I would do, is access the database, see when they last visited, and seeing if that is less than x amount.? Quote Link to comment https://forums.phpfreaks.com/topic/121739-time-access/#findComment-628030 Share on other sites More sharing options...
rhodesa Posted August 28, 2008 Share Posted August 28, 2008 correct....more detailed help requires more info on what you are trying to do... are you trying to block them all together? just one page? several pages which have independent trackers per user? Quote Link to comment https://forums.phpfreaks.com/topic/121739-time-access/#findComment-628033 Share on other sites More sharing options...
wwedude Posted August 28, 2008 Author Share Posted August 28, 2008 Just one page. Quote Link to comment https://forums.phpfreaks.com/topic/121739-time-access/#findComment-628036 Share on other sites More sharing options...
rhodesa Posted August 28, 2008 Share Posted August 28, 2008 so yeah, just add a column to your users table (or create a new table that you can do a JOIN with). make the column an INT or a DATETIME type. The following code assumes it's an INT type and should be put at the top of that page. <?php //Put the code that confirms the person is logged in here //Assuming the user's unique identifier is $userid //Select the value from the lastVisit field and store it into $lastVisit list($lastVisit) = mysql_fetch_array(mysql_query("SELECT `lastVisit` FROM `users` WHERE `userid` = '{$userid}' LIMIT 1")); //Check the time $diff = 60 * 60 * 24; //1 day in seconds if($lastVisit && time() - $lastVisit < $diff){ print "Denied"; exit; } //Update table mysql_query("UPDATE `users` SET `lastVisit` = '".time()"' WHERE `userid` = '{$userid}' LIMIT 1"); //Continue with page ?> Quote Link to comment https://forums.phpfreaks.com/topic/121739-time-access/#findComment-628091 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.