Cookie Problem , assistant need !

Discussion in 'ASP.NET / ASP.NET Core' started by silkkeng, Dec 21, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi all, I've already tried by best but I can't find out what my problem is.
    I have the code as below :



    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load





    If Request.Cookies("LCK") Is Nothing Then


    Me.Visible = True


    Else


    Me.Visible = False


    End If


    End Sub


    Public Sub CookieAdd(ByVal email As String)


    Dim locookie As HttpCookie


    locookie = New HttpCookie("LCK")


    locookie.Values.Add("UID", email.ToString)


    locookie.Expires = DateTime.Now.AddDays(1)


    locookie.Secure = True


    HttpContext.Current.Response.Cookies.Add(locookie)


    End Sub


    Public Sub CookieRemove()


    Dim locookie As HttpCookie


    locookie = HttpContext.Current.Request.Cookies("LCK")


    If locookie.Value <> "" Then


    locookie.Expires = DateTime.Now.AddHours(-2)


    HttpContext.Current.Response.Cookies.Add(locookie)


    End If


    End Sub


    Public Function CookieExist() As Boolean


    Dim cookie As HttpCookie


    If Not HttpContext.Current.Request.Cookies("LCK") Is Nothing Then


    Return True


    Else





    Return False


    End If


    End Function


    Public Function CookieGet() As String


    If Not HttpContext.Current.Request.Cookies("LCK") Is Nothing Then


    Return HttpContext.Current.Server.HtmlEncode(HttpContext.Current.Request.Cookies("LCK").Value)


    End If


    End Function





    On Authentication , I have set the value of cookie



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


    CookieRemove()


    End If


    CookieAdd(uc.Email.ToString)



    Response.AppendHeader("Refresh", "1;URL=testing.aspx?logged=true")


    I have no idea why there is no value on Request.Cookies("LCK")


    can anyone explain to me the step to using cookie in asp.net 1.1 ?
    Or perhaps telling me what's wrong with my code ? As I can still see my cookie text file on my local machine.[​IMG]



     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page