Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

手机微信和webview中localStroage.clear() 清理失败 这是什么鬼? #151

Open
mishe opened this issue Feb 8, 2017 · 0 comments

Comments

@mishe
Copy link
Owner

mishe commented Feb 8, 2017

  • 最近在忙一个运营活动,测试在多用户交叉测试时,发现一个诡异的问题:

  • 登录用户A,访问活动页,看到了A的相关信息,也可以进行相应的操作,然后退出用户A,在进活动页,有几率看到的页面还是用户A的信息。

检测用户退出的代码:

localStorage.clear();
location.reload();

可以看到明确的调用了clear方法。

但是localStroage就是没有清除,这个可以由fiddler 的抓包数据可以证明。

这是碰上什么鬼?

百度了下:可以查到
https://segmentfault.com/q/1010000002739402
这个帖子,但回答的牛头不对马嘴

还是得靠google了,可以查到如下的地址

http://stackoverflow.com/questions/7667958/clear-localstorage

thoughtbot/capybara-webkit#301

看上去似乎是webkit的事啊,那么在无法控制webkit升级的情况下,怎么解决这个问题呢?

我尝试了如下代码

 localStorage.clear();
 setTimeout(function(){
       if(localStorage.length>0){
               window.localStorage.clear();
        }
        location.reload();
 },50);

调用clear后,在通过一个延时检测localstorage是否真的已经没有数据了,如果还有,在清理一次

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant