javascript - The page returns to the previous level and the processed data is returned repeatedly?
ringa_lee
ringa_lee 2017-05-16 13:07:04
0
3
350

There is a function on the homepage of the mall, that is, when a user logs in for the first time that day, a [Points + 10] prompt will be given to the user on the homepage

Describe how the bug occurred:
When I logged in for the first time that day, a prompt of [Points +10] popped up. Then at this time, I clicked on any link on the homepage and clicked on that link. When returning, when I return to the homepage, the prompt [Points +10] will still appear repeatedly.

But it shouldn’t be, because I already have logic processing in the background. When the user logs in for the first time that day, a record is inserted into the table and 200 is returned. If the user has already logged in, 202 is returned. , the front desk prompts based on the return status code, but when returns to the homepage from the previous page, there will still be a prompt. If I refresh the homepage again, the prompt will disappear

I compared it twice (The page just entered and The page returned from the previous level) and the results returned by the url were both 200, this is very strange

Post the code:
js

< /p>

php

< /p>

Please help~


Get requests will be cached by the browser, orz~

ringa_lee
ringa_lee

ringa_lee

reply all(3)
迷茫
<?php
session_start();
if ($_POST){
    if(!$_SESSION['status2']){
        echo 1;
    $_SESSION['status2']=1;
    } else {
        echo 2;
    }
}

<script>
  $.post('./test.php',{statue:1},function(e){
    alert(e);
  })
</script>

After testing it like this, I found that there is no problem. It is recommended that you trace the code to determine whether you have logged in. Is there any cache or other factors that may affect it?

小葫芦

Is there any problem with the login status judgment of total?

漂亮男人

Consider whether it is the impact of caching.
Check to see if the points have indeed increased twice in the background. If it does not increase the second time, it means that your background logic is correct, and it may be caused by browser cache. If the background is indeed increased, then the background logic is wrong.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template