Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookies

Status
Not open for further replies.

conjurer111

Programmer
Aug 11, 2002
76
IN
Hi,

I'm making a site in ASP.NET and I need to do the following. I have a login page where in when a user logs on, I need to store his username and email id in cookies. Later I'll need to retieve these values from other pages. So, what shall be the codes to set a coookie and retrieve it. Also, I need to check whether the client machine has disabled cookies, and if so then what all alternatives do I have apart from posting a message to enable cookies ? Thanks.
 
Conjurer,

Here is one way to set cookies:

Dim ASPNetCookie As New HttpCookie("ASPNetCookie")
Dim dt As DateTime = DateTime.Now
Dim ts As New TimeSpan(1, 0, 0)
ASPNetCookie.Expires = dt.Add(ts)
ASPNetCookie.Item("UN") = txtUserName.text
ASPNetCookie.Item("EMAIL") = txtEmail.text
Response.Cookies.Add(ASPNetCookie)

Hope this helps.
Nat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top