Thursday, March 22, 2012

Newbie in .NET - Cookie Tutorial?

Hello

I'm creating a site with ASP .NET 2.0 and VB .NET. I want to use cookies to remember want the user entered in previously. I've never used cookies before so I was wondering if there is a good online tutorial about?

Thanks

Kev.

"A stitch in time would have confused Einstein. " - Unknown.http://www.codetoad.com/asp.net/cookies.asp

Just remember never to use Response.Write like they have in that tutorial.
What should be used instead of response.write?
Controls.
At the moment I'm using -

Dim Cookie As HttpCookie = New HttpCookie("BuyerSellerLogin")

Cookie.Values.Add("regnumber", Request.Form.Item("regnumber"))
'Cookie.Values.Add("username", username.Value)
Cookie.Expires = #1/1/2007#
Response.Cookies.Add(Cookie)

And to retrieve I'm using

Dim c As HttpCookie = Request.Cookies("BuyerSellerLogin")

If Not (IsNothing(c)) Then
regnumber.Value = Request.Cookies("BuyerSellerLogin")("regnumber")
End If

how would you store a list of values into a cookie and bring them back. For example one of the fields I'm using is Vessel Name. I want to give the user a list of all previously entered vessel names?

KEv.

0 comments:

Post a Comment