session - 为什么 session 放弃不起作用?

标签 session asp-classic iis-6

我有以下代码

cx5_login.asp

Session("Login") = "demo"

cx5_logout.asp :

Session("Login") = ""
Session.Abandon
response.redirect "c5x_login.asp?C5xName=Login"

我想知道Session.Abandon是否会移除Session("Login")? 目前,我正在检查 Session("Login") 以确定用户是否登录。 但它不起作用。

场景:

  1. 用户登录
  2. 用户注销
  3. 我从 Session("Login") 打印值,它仍然有值(value)。

我已经调用了 Session.Abandon 但为什么 Session("Login") 仍然有值(value)? 它与 ASPSESSIONID cookie 有关吗? 我尝试手动删除该 cookie,它成功了。

有什么解释吗?

最佳答案

什么 Neel say's没有错,但也不对,问题是并且经常倾向于提问者或回答者将经典 ASP 与 ASP.Net 混淆。

如果您的问题与经典 ASP 相关,那么在谈论 Session 时您需要考虑以下问题。

Session.Abandon() 应该用于完全处理一个 session ,包括 Session.SessionID

但是有一个洞穴;

Quote from the MSDN Library - Session.Abandon()

"When the Abandon method is called, the current Session object is queued for deletion but is not actually deleted until all of the script commands on the current page have been processed. This means that you can access variables stored in the Session object on the same page as the call to the Abandon method but not in any subsequent Web pages."

这意味着在当前页面的上下文中,您的 Session 仍然可用,直到您转到另一个页面时,Session 对象才真正被释放。

如果您在注销页面后不重定向,您的 session 仍然可以访问,但请放心,在离开该页面后访问它的任何尝试都将失败。

As a test don't automatically redirect after logout but give the users a link to press and see if you get the same behaviour.

关于session - 为什么 session 放弃不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23404115/

相关文章:

tomcat - 在不同端口上运行 Railo/Tomcat IIS6 站点

c# - 在存储库线程中锁定单个 session 是否安全? (N休眠)

ios - 在 opentok 2.1.7 版本中永远不会调用 "session receiveSignalType"

php - session 过载 - PHP session 中存储的 "too much data"是什么?

asp-classic - ASP - 从字符串中删除双引号

windows - IIS6 Windows 身份验证仅在通过 DNS 名称(而非 IP 地址)访问站点时有效

asp.net-mvc - 将子应用程序托管到主应用程序,无需更改 URL

.net HttpCookie 类/ session cookie 问题

perl - 使用 perl mechanize 抓取 ASP 站点

asp-classic - vbscript:带参数的getref