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 ;}