Asp.net 无法在ie中获取cookie

Asp.net 无法在ie中获取cookie,asp.net,asp.net-mvc,internet-explorer,cookies,Asp.net,Asp.net Mvc,Internet Explorer,Cookies,我在cookie中存储了一些用户数据。它在chrome和mozilla中运行良好。但在IE中,它无法获取cookie。我使用的是IE版本10。请帮帮我 以登入形式: Dim Mydtt As String = "my custom data " Dim authTicket = New FormsAuthenticationTicket(2, usrid, Date.Now, Date.Now.AddDays(7), True, Mydtt, "/")

我在cookie中存储了一些用户数据。它在chrome和mozilla中运行良好。但在IE中,它无法获取cookie。我使用的是IE版本10。请帮帮我

以登入形式:

        Dim Mydtt As String = "my custom data "
        Dim authTicket = New FormsAuthenticationTicket(2, usrid, Date.Now, Date.Now.AddDays(7), True, Mydtt, "/")

        Dim cookie As New HttpCookie("usrlg", FormsAuthentication.Encrypt(authTicket))
        Response.Cookies.Set(cookie)
        Response.Redirect("~/phed/reports")
会话启动中:

        Dim LastLoginCookie As HttpCookie
        LastLoginCookie = HttpContext.Current.Request.Cookies.Get("usrlg") ' Return Nothing in IE '
        Dim LastLgTicket As FormsAuthenticationTicket = FormsAuthentication.Decrypt(LastLoginCookie.Value)
        Dim Mydtt As String = LastLgTicket.UserData

您可能希望在解密之前检查空值

Dim LastLoginCookie = HttpContext.Current.Request.Cookies("usrlg")

If LastLoginCookie IsNot Nothing Then
   Dim LastLgTicket As FormsAuthenticationTicket = 
      FormsAuthentication.Decrypt(LastLoginCookie.Value)
   Dim Mydtt As String = LastLgTicket.UserData
End If
类似的答案。

据我所知,cookie.Secure必须正确设置,即HTTP为false,HTTPS为true。 您可以使用请求对象自动检测协议:

cookie.Secure = Request.IsSecureConnection;
Response.Cookies.Set(cookie);

希望这有帮助。

您能尝试使用版本1和默认cookie路径-。。。新表单sauthenticationticket1、usrid、DateTime.Now、DateTime.Now.AddDays7、true、Mydtt、FormsAuthentication.FormsCookiePath;请看我答案中的链接。我尝试过Dim cookie作为新的HttpCookieusrlg,FormsAuthentication.EncryptauthTicket cookie.Secure=FormsAuthentication.RequireSSL cookie.Path=FormsAuthentication.FormsCookiePath cookie.Domain=FormsAuthentication.cookie域响应.cookie.SetCookie不适用于IE,但适用于Chrome。为什么会发生这种情况?它也会发生在其他计算机上吗?如果不是,您的IE设置可能会有问题。我很好奇普通的cookie是否能在你的IE浏览器中使用。用来测试它。