PHP limits frequent requests

Source: Internet
Author: User
: This article mainly introduces PHP restrictions on frequent requests. For more information about PHP tutorials, see.
 * @ Link http://www.jieone.com/ */Class Token extends RSA {/*** unique client ID */private $ date = 0; private $ clientID = "abccccc";/*** system access_token, that is, the data to be saved on the client */private function sys_access_token () {$ array = array ('clientid' => $ this-> clientID, 'date' => $ this-> date); $ sys_access_token = json_encode ($ array); // RSA public key encryption return $ this-> public_encrypt ($ sys_access_token );} /*** save access_token */public function get_access_token () {if (empty ($ _ COOKIE ['Access _ token']) {$ this-> date = time () -100; return $ this-> sys_access_token ();} return $ _ COOKIE ['Access _ token'];}/*** save access_token */private function save_access_token () {setcookie ("access_token", $ this-> sys_access_token ();} public function check () {$ access_token = $ this-> get_access_token (); // RSA private key decryption $ access_token = $ this-> private_decrypt ($ access_token); // The information has been illegally tampered with if (empty ($ access_token) {return false ;} $ object = json_decode ($ access_token); // ajax requests can be requested only once in 2 seconds. you can modify if ($ object-> date + 2> time () {return false ;} // save access_token $ this-> date = time (); $ this-> save_access_token (); return true ;}} echo'





Try refreshing frequently
'; $ Token = new Token (); if (! $ Token-> check () {echo' Your request is too fast. please try again later


'; Exit ();} echo' Access normal


'; Echo "your current access_token:". $ Token-> get_access_token ();

The above section describes the restrictions on frequent requests in PHP, including some content, and hopes to help those who are interested in PHP tutorials.

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.