Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts

    Using time code for server time

    I would like to make a part in my script for a function to only be available every 24 hours. Once they click it, they can't click it again for 24 hours (from the set server time). So if they click it at 3pm and the server reset time for it is midnight. It won't be available again until 12:00am.

  • #2
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Use a database to store their last clicked time. When they come to the page again, look at the day+month of today versus the day+month of when they last clicked and if it is different, show it again.

  • #3
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    So I can put a timestamp on the database. I believe I use timeNOW() to record or check the current time?

  • #4
    New Coder
    Join Date
    Apr 2007
    Posts
    89
    Thanks
    1
    Thanked 2 Times in 2 Posts
    using the db seems a but resource heavy.
    PHP Code:

    if(isset($_GET["click"]) ){
        if(isset(
    $_COOKIE['foo']))
        {
        
    //if cookie exists skip code
        
    }else{
        
    setcookie($name$cookievaluetime() + 43200);
     
    // if cookie doesn't exist then create cookie and run code
        
    code();
        }


  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    That makes no sense. They could clear their cookies and click it all over again without having to wait. Besides, from posts I get the impression that masterofollies is using a database already, if not a full login system.

  • #6
    New Coder
    Join Date
    Apr 2007
    Posts
    89
    Thanks
    1
    Thanked 2 Times in 2 Posts
    true I forgot you could delete cookies, yea a db is the best way to go then


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •