Problem with retrieving cookie in ASP.net

S

SV

I have a login form with “Remember me on this computer” checkbox. I am
creating cookie if checkbox is checked. My code is:

If chk_remember.Checked = True Then

Dim ckUserName As HttpCookie = New
HttpCookie("CTUserName")
ckUserName.Value = Trim(txt_unm.Text)
ckUserName.Expires =
System.DateTime.Now.AddYears(4)
Response.Cookies.Add(ckUserName)
ckUserName = Nothing

End If


Now I am retrieving cookie on page load. It always gives me blank text
box of username. I don’t understand why it gives null. Is that I am
doing anything wrong?
My code for retrieving cookie is:

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

txt_unm.Text = Request.Cookies("CTUserName").Value

End If

Any help will be appreciated.

Thanks,
SV
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Check For Cookies 2
cookie textbox value problems 3
Cookie. Urgent. Thank You. 3
Can't Update of Cookie 2
Weird cookie problem 2
Object reference error with cookie 6
cookies in asp.net 2
Cookie Question 1

Top