PHP Records access times with cookies

Source: Internet
Author: User
  1. $f _open = fopen ("Count.txt", "r+"); Opens the specified file
  2. $count = fgets ($f _open); Reading data from a file
  3. if (Empty ($_cookie[' cookie_name ')) {//To determine if a COOKIE exists
  4. Setcookie ("Cookie_name", Value,time () +1800); Create a cookie if it does not exist
  5. $count = $count + 1; Add 1 to the value of the variable $count
  6. Rewind ($f _open); Opens the specified file
  7. Fwrite ($f _open, $count); Writing new data to a file
  8. Fclose ($f _open); Close File
  9. }
  10. ?>
Copy Code
PHP, cookies
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.