473,326 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Problem with retrieving cookie in ASP.net

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
Jun 27 '08 #1
2 1180
"SV" <sw*******@gmail.comwrote in message
news:cc**********************************@x19g2000 prg.googlegroups.com...
Any help will be appreciated.
Does this work: ?

txt_unm.Text = Server.HtmlEncode(Request.Cookies("CTUserName").Va lue)
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #2
SV
Ahhh, It is solved now.

Thanks Mark.
On May 7, 6:26*pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"SV" <swetav...@gmail.comwrote in message

news:cc**********************************@x19g2000 prg.googlegroups.com...
Any help will be appreciated.

Does this work: ?

txt_unm.Text = Server.HtmlEncode(Request.Cookies("CTUserName").Va lue)

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Vikram Bhatia | last post by:
In my web application we are able to store large data in the browser cookie keeping in mind the limit of 300 cookies per cookie file, 20 keys per cookie per domain and 4KB max size of each cookie....
0
by: John Smith | last post by:
I have a cookie that contains two subkeys. I am trying to read one of the subkeys via the <asp:CookieParameter>, but I can't seem to specify which subkey to get. ASP.NET seems to only want to...
7
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the...
1
by: angela | last post by:
Hi, Quick question: I have set a persistent cookie on my login page and have the following in the web config. <forms name="BeanAppAuth" loginUrl="Login.aspx" protection="All" /> I know I...
1
by: SamG | last post by:
Hello, Does anyone know how I can Write a Cookie and then later retrieve it...? Also, Is it possible to write attributes and corresponding values to the cookie file.Needless to say would require...
1
by: asg | last post by:
I have the code below that will retrieve a cookie that was placed by the server (ie: joes.com) that the document resides on. I want to be able to retrieve a cookie set by another server (ie:...
2
by: teddarr | last post by:
I want to write a cookie that will hold purchase information. The name of this cookie will be a julian date/time. How do I go about retrieving all the cookies within a certain time period? ...
2
by: miraan | last post by:
Hi, I set a php cookie on one page, is it possible to retrieve the same cookie on another webpage on my site or can i just retrieve the cookie from the page that i set the cookie on?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.