IE8 does not save session variables

If I host an ASP.NET page using

<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">

    protected void btn_Click(object sender, EventArgs e)
    {
        lbl.Text = HttpContext.Current.Session["a"] == null ? 
                      "null" : 
                      HttpContext.Current.Session["a"].ToString();
    }
    protected void btn_Click2(object sender, EventArgs e)
    {
        lbl.Text = HttpContext.Current.Cache["a"] == null ? 
                      "null" : 
                      HttpContext.Current.Cache["a"].ToString();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            HttpContext.Current.Session["a"] = "CBA";
            lbl.Text = "assigned Session Variable";

            HttpContext.Current.Cache.Add(
                    "a", "ABC", null, 
                    DateTime.Now.AddHours(2), TimeSpan.Zero, 
                    CacheItemPriority.NotRemovable, null);
        }
    }

</script>

<html>
<head>
    <title>Testing Session</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="btn" runat="server" Text="read Session" OnClick="btn_Click" />&nbsp;&nbsp;
        <asp:Button ID="btn2" runat="server" Text="read Cache" OnClick="btn_Click2" />
        <hr />
        <asp:Label ID="lbl" runat="server" />
    </div>
    </form>
</body>
</html>

in the first run I get the text assigned Session Variable, but after clicking on the Session object alwaysnull

Do I have an option that I need to enable / disable in order to use regular session variables?

works great on IIS 6.0 and Cassini (in VS 2008 and 2010).

I start with no idea what is going on: o (

Any help is much appreciated!


sample page process above

alt text

alt text


Additional tests show that this only happens in IE (i.e. in this case), Firefox, Safari, Opera, Chrome, they all give the correct answer

alt text


check the screenshot of the situation

+5
2

. _ , .

+2

cookie .

- , IE8 cookie? .. - "... "

0

All Articles