0

Hi all,

I want to get a cookies value from one .aspx.vb page to another .aspx.vb page.but i can not get it.
i give the code bellow:
This is in:(webForm2.aspx.vb):in this page I set the Cookies value
webForm2.aspx.vb
(code):

Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
            Dim str2 As String
            Request.Cookies.Remove("userInfo")
            str2 = "myValue"
            Response.Cookies("userInfo")("userName") = str2
            Response.Cookies.Add(aCookie)
            Dim str5 As String = Server.HtmlEncode(Request.Cookies("userInfo")("userName"))
            Response.Redirect("webForm1.aspx")
        End Sub

I can not retrieve cookies value from another page :webpage1.aspx.vb:
webForm1.aspx.vb
(code):

If Not Request.Cookies("userInfo") Is Nothing Then
            Dim aCookie As HttpCookie = Request.Cookies("userInfo")
            Dim str As String = Server.HtmlEncode(Request.Cookies("userInfo")("userName"))
        End If

::: Here if condition is execute but the cookies value is "".
So, how can get cookies value ?

Thank you in advance.

Edited by deceptikon: Moved to ASP.NET

4
Contributors
3
Replies
7
Views
5 Years
Discussion Span
Last Post by G_Waddell
0

Why do you need to store username in cookie? ASP.NET gives you Page.Identity.User.Name in every page automatically for you.

More on cookies here

More on authentication here

Edited by hollystyles

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.