Phpcookie read settings delete instances

Source: Internet
Author: User
Phpcookie read settings delete instance the article uses two instances to describe how php sets cookies, reads cookies, deletes cookies, and other processing methods.

Php cookie reading settings delete instance article uses two instances to describe how php sets cookies, reads cookies, deletes cookies, and other processing methods. if you need to update cookies to store new values, you only need to overwrite the original value. Therefore, you can change your name to "jeff" even if you have just sent a cookie on the previous page ".

$ Y2k = mktime );

Setcookie ('name', 'Jeff ', $ y2k );

The above is a simple cookie instance. next we will look at a complicated cookie for user login verification instance code.

  1. Function verify ()
  2. {
  3. Global $ pass;
  4. If ($ _ post ['pass'] = $ pass | $ _ cookie ['pass'] = md5 ($ pass ))
  5. {
  6. Cookie (true );
  7. Return true;
  8. }
  9. Else
  10. {
  11. Cookie (false );
  12. Return false;
  13. }
  14. }
  15. Function cookie ($ set = true)
  16. {
  17. Global $ pass;
  18. If ($ set)
  19. Setcookie ("pass", md5 ($ pass), time () + 3600 );
  20. Else
  21. Setcookie ("pass", "", time ()-3600 );
  22. }

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.