javascript - 页面返回上一层 重复返回已处理过的数据?
ringa_lee
ringa_lee 2017-05-16 13:07:04
0
3
311

商城首页有个功能,就是当用户当天首次登陆的时候,会在主页上给用户一个【积分+10】的提示

描述下bug出现的经过:
当我当天第一次登陆的时候,会弹出【积分+10】的提示,然后这时候我在主页上点击任意一个链接,并在那个链接点击返回的时候,这时候回到了主页,还是会重复出现【积分+10】的提示。

但是不应该啊,因为我在后台已经有了逻辑处理,当用户当天首次登陆的时候插入记录到表,并返回200,如果已经登录过返回202,前台根据返回状态码进行提示,但是当从上一页返回到主页的时候还是会有提示出现。如果我在主页重复刷新一次的话,提示就没有了

我比较了一下两次(刚进入页面从上一层返回过来的页面)url返回的结果都是200,这就很奇怪了

贴一下代码:
js

php

求解救~


get请求会被浏览器缓存,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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!