A judgment problem

Source: Internet
Author: User
If a problem is identified, the test () function is executed once when a cookie is logged on. no matter how to refresh the member center page, the test () function is executed only once. how can this problem be solved? Let's give a thought. counting is enough. + 1 after execution. if the value is greater than 1, no execution is performed ., Session record. if it is recorded, it will not be executed ., Count. Hold a judgment question
If you have already logged on to the cookie, run the test () function once. no matter how you refresh the member center page, only test () is executed once. how can this problem be solved? Give a thought

------ Solution --------------------
Counting is enough. + 1 after execution. if the value is greater than 1, no execution is performed.
------ Solution --------------------
Session record. if it is recorded, it will not be executed.
------ Solution --------------------
Discussion

Counting is enough. + 1 after execution. if the value is greater than 1, no execution is performed.

------ Solution --------------------
If you do not know how to define and use your cookies, you can define a cookie to control whether test () is executed.
------ Solution --------------------
PHP code
If (isset ($ _ SESSION ['hastest ']) & $ _ SESSION ['hastest'] = true) {// do nothing} else {test (); $ _ SESSION ['hastest '] = false ;}

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.