谷歌浏览器会话变量仍然存在浏览器关闭后 [英] Session variables in Google Chrome persist after browser closes

查看:406
本文介绍了谷歌浏览器会话变量仍然存在浏览器关闭后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的会话变量来存储一些数据。我想在浏览器关闭丢失数据,或会话超时。一切工作在IE和FF,但仍存在铬会话变量浏览器已经关闭了。

I'm using session variable to store some data. I want the data to be lost when the browser closes, or session times out. Everything works in IE and FF, but chrome persists session variables after browser has been closed.

var myName = Session["Name"];

if (myName == null) {
  myName = "defaultName";

}

这不会落入IF块,如果我关闭并重新打开Chrome,作为会话变量依然存在。
有没有一种方法,以确保谷歌的Chrome关闭后会话变量都将丢失?​​

It will not fall into the if block if i close and re-open chrome, as the session variable is persisted. Is there a way to ensure session variables are lost after google's chrome is closed ?

推荐答案

记住HTTP是无状态协议,所以你不能确定某个用户关闭浏览器或浏览器窗口中打开。这是我们的的原因使用会话超时 - 可以减少暂停时以关闭非活动会话,但是这可能会导致其他用户有自己的会话超时

Remember HTTP is a stateless protocol, so you cannot determine if an user has closed the browser or with browser window open. This is the reason we use sessions timeout - you can reduce the timeout in order to close inactive sessions, but this may lead to other users to have their session timed out.

浏览器关闭并不意味着会话被破坏。不过,如果一些空闲时间后销毁。

Closing browser doesn't mean the Session is destroyed. But would be destroyed after some idle time.

阅读:会话处理一些变通方法,对如何处理会话超时更好

Read this : Session Handling for some work around methods on how to handle session timeouts better

这篇关于谷歌浏览器会话变量仍然存在浏览器关闭后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆