传统的ASP:多个ASPSESSIONID在饼干 [英] Classic ASP: Multiple ASPSESSIONID in cookies

查看:695
本文介绍了传统的ASP:多个ASPSESSIONID在饼干的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个传统的ASP页面的一个问题,我只是解决不了它,因为3天。

I have a problem with a classic asp page and I just cannot solve it since 3 days.

该页面正在与会话 - 有时它发生的ASPSESSIONID饼干在Request.ServerVariables设置两次(HTTP_COOKIE)。这将导致ASP页到两次会议之间跳转的页面被刷新时。

The page is working with Sessions - sometimes it happens that the ASPSESSIONID cookie is set twice in the Request.ServerVariables("HTTP_COOKIE"). This causes the ASP-Page to jump between the two Sessions when the page is refreshed.

我已经写它输出当前的SessionID,服务器软件和HTTP_COOKIE值的测试页。

I have written an Test page which outputs the current SessionId, the Server Software and the HTTP_COOKIE value.

示例输出:

会话ID:308542840

Session ID: 308542840

会话超时:20分

服务器软件:Microsoft-IIS / 6.0

Server Software: Microsoft-IIS/6.0

HTTP_COOKIE:ASPSESSIONIDQCBATRAD = MBHHDGCBGGBJBMAEGLDAJLGF; ASPSESSIONIDQCCDTTCB = PGHPDGCBPLKALGGKIPOFIGDM

HTTP_COOKIE: ASPSESSIONIDQCBATRAD=MBHHDGCBGGBJBMAEGLDAJLGF; ASPSESSIONIDQCCDTTCB=PGHPDGCBPLKALGGKIPOFIGDM

为什么有两个ASPSESSIONIDs?
当我刷新页面,然后它随机输出两个Session ID之一。

Why are there two ASPSESSIONIDs? When I refresh the page then it randomly outputs one of the two Session IDs.

下面是一个截屏,显示在IE9的问题:
http://prinz-alexander.at/asp_test.avi

Here is a screencast which shows the problem in IE9: http://prinz-alexander.at/asp_test.avi

这个错误通常发生在IE8和IE9。

This error often occurs in ie8 and ie9.

只要做到以下重现问题:

Just do the following to recreate the Problem:


  1. 完全关闭IE8或IE9

  2. 启动IE8或IE9和开放 http://www.pfiffikus.at/pfiffikus/tests/

  3. 后立刻加载页面刷新页面多发时间

如果您重复此步骤,然后随机(不总是)在HTTP_COOKIE填充了两种不同的ASPSESSIONIDs。

If you repeat this steps then randomly (not always) the HTTP_COOKIE is populated with two different ASPSESSIONIDs.

在ASP测试文件只在允许输出值mentiod,没有别的发生在源$ C ​​$ C。

The asp test file is only outputing the mentiod values, nothing else is happening in the source code.

这是asp的测试文件的code:

This is the code of the asp test file:

<% If trim(Session("test_val")) = "" Then
     Dim my_num
     Randomize
     number = Int((rnd*1000))+1
     Session("test_val") = number
   End If
%>

<b>Session ID:</b>
<% response.write(Session.SessionId) %><br /><br />

<b>Session("test_val"):</b>
<% response.write(Session("test_val")) %><br /><br />

<b>Session Timeout:</b>
<% response.write(Session.Timeout) %> minutes<br /><br />

<b>Server Software:</b>
<% response.write(Request.ServerVariables("SERVER_SOFTWARE")) %><br /> <br />

<b>HTTP_COOKIE:</b> <% response.write(Request.ServerVariables("HTTP_COOKIE")) %>

我怎样才能避免多重ASPSESSIONIds在饼干?

How can i avoid multiple ASPSESSIONIds in cookies?

感谢您的帮助!

推荐答案

我能够删除这些cookie使用Javascript。

I was able to remove those cookies with Javascript.

只是下一个脚本添加到登录页面的末尾。
这将删除所有的ASPSESSIONIDXXXXXXX饼干之前用户登录网站:

Just add next script to the end of login page. This will remove all "ASPSESSIONIDXXXXXXX" cookies before user will login to website:

<script type="text/javascript">
    //Clear any session cookies
    (function(){
        var i;
        var cookiesArr;
        var cItem;

        cookiesArr = document.cookie.split("; ");
        for (i = 0; i < cookiesArr.length; i++) {
            cItem = cookiesArr[i].split("=");
            if (cItem.length > 0 && cItem[0].indexOf("ASPSESSIONID") == 0) {
                deleteCookie(cItem[0]);
            }
        }

        function deleteCookie(name) {
            var expDate = new Date();
            expDate.setTime(expDate.getTime() - 86400000); //-1 day
            var value = "; expires=" + expDate.toGMTString() + ";path=/";
            document.cookie = name + "=" + value;
        }
    })();
</script>

这篇关于传统的ASP:多个ASPSESSIONID在饼干的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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