How can I change this php code?

Source: Internet
Author: User
I want to generate a token and display it. The page is refreshed and changed once. How can I modify the following code? {Code...} I want to generate a token and display it. The page is refreshed and changed once. How can I modify the following code?


  

Reply content:

I want to generate a token and display it. The page is refreshed and changed once. How can I modify the following code?


  

Can't you change the page once you refresh it?
If it is me, the following code is like this

Session_start (); function set_token () {$ key = mt_rand (100000,900000); $ token = md5 (md5 (time ()). $ key); $ _ SESSION ['Token'] = $ token; return $ token;} function get_token () {if (! Isset ($ _ SESSION ['Token']) | empty ($ _ SESSION ['Token']) {return false ;} return $ _ SESSION ['Token'];} function unset_token () {unset ($ _ SESSION ['Token']);} function valid_token ($ token) {if ($ token! ==$ _ SESSION ['Token']) {return false;} return true ;}$ token =$ _ REQUEST ['Token']; // tokenif (get_token () === false) submitted by the client {$ token = set_token (); echo 'Verification Failed! '; Echo': '. $ token;} else {if (valid_token ($ token) {echo' is verified successfully! '; Unset_token (); // Delete token $ token = set_token (); echo' New token generated: '. $ token ;}}

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.