Etienne
Etienne

Reputation: 7191

Something wrong when i want to read my cookie - using ASP.NET

I am using ASP.NET and VB.NET 2.0.....................................

This is my code i use when i create my 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

And this is my code i use on a Page Load Event to read that Cookie but i cant read it?

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

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

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

        End If

What am i doing wrong????

Upvotes: 0

Views: 401

Answers (1)

Ben Schwehn
Ben Schwehn

Reputation: 4565

Since you set your cookie as New HttpCookie("LoginInfo") , you should read it using

Request.Cookies("LoginInfo"), not

Request.Cookies("Email").

Upvotes: 6

Related Questions