bahare g

bahare g

  • NA
  • 68
  • 0

cookie

Nov 23 2010 8:39 AM
Hi All my friends 
I want to write a login page. I want to define a  cookie for maintan username in it and I expect this cooki stay in her\his client computer for her\his next referal( if that cookie there is on her\his computer there is no need to login and i show her\him welcome message)

i use below code but i didn't safe result.the cookie destroy.

code for save cooki in client  
 Response.Cookies("username").Value = txtUserName.Text.Trim
   Response.Cookies("username").Expires = DateTime.Now.AddDays(4)

code for retrive it

 If Not (Page.IsPostBack) Then
            If Request.Cookies("username") IsNot Nothing Then lbluser.Text = Request.Cookies("username").Value 
        End If

Answers (1)