PHP restricts frequent requests

Source: Internet
Author: User
  * @link http://www.jieone.com/*/class Token extends rsa{/** * Client unique ID */private $date =0;private $clientID = "ABCCCCC";/** * System Access_token, that is, data to be stored 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);//information has been illegally tampered with if (empty ($access _token)) {return false;} $object =json_decode ($access _token);//2 seconds can only be Ajax requested once, can modify if ($object->date + 2 > Time ()) {return false;} Save Access_token$this->date=time ();$this->save_access_token (); return true;}} Echo '





Frequent refresh try


'; $Token =new Token (); if (! $Token->check ()) {echo '

You requested too fast, please try again later




'; exit ();} Echo '

Access to normal




'; Echo ' Your current Access_token: '. $Token->get_access_token ();

The above describes the PHP limit of frequent requests, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.