【问题标题】:Something wrong when i want to read my cookie - using ASP.NET当我想读取我的 cookie 时出现问题 - 使用 ASP.NET
【发布时间】:2023-04-01 01:43:01
【问题描述】:

我正在使用 ASP.NET 和 VB.NET 2.0....................... .

这是我创建 Cookie 时使用的代码

If dlgLogin.RememberMeSet = True Then

        Dim RateCookie As New HttpCookie("LoginInfo")

        RateCookie.Values("Email") = dlgLogin.UserName
        RateCookie.Values("Password") = dlgLogin.Password
        RateCookie.Expires = DateTime.Now.AddDays(100)
        Response.Cookies.Add(RateCookie)

    End If

这是我在页面加载事件中用来读取 Cookie 但我无法读取的代码?

 If Not Request.Cookies("Email") Is Nothing Then

            Dim RateCookie As HttpCookie = Request.Cookies("Email")

            Session("myEmailSession") = Server.HtmlEncode(RateCookie.Value)

        End If

我做错了什么????

【问题讨论】:

  • 有什么问题?什么不工作,你得到什么错误。问题中的“有问题”并不是很多事情要继续
  • 我不确定它是否真的在我创建它时保存了我的 cookie....因为我似乎无法读取 Cookie..........

标签: c# asp.net vb.net cookies


【解决方案1】:

由于您将 cookie 设置为 New HttpCookie("LoginInfo") ,您应该使用

阅读它

Request.Cookies("LoginInfo"), 不是

Request.Cookies("Email")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-03
    • 1970-01-01
    相关资源
    最近更新 更多