' Cookies_Save_and_Recall.vb.txt ' Writen by Dan Garlen dan.g@kgsystems.com ' Last Modified" 3/20/04 ' ' Create new WebForms named Cookies ' Add label Control (leave default name of "Label1") ' Add TextBox Control (leave default name of "TextBox1") ' Add Two buttons named btnSaveCookie & btnRecallCookie Paste the following three subroutines into your codebehind page Private Sub btnSaveCookie_Click(...) _ Handles btnSaveCookie.Click Dim objCookie As New HttpCookie("UserName") objCookie.Value = TextBox1.Text Dim dtCookieExpire As DateTime = _ Now.Today.AddDays(2) objCookie.Expires = dtCookieExpire Response.Cookies.Add(objCookie) End Sub Private Sub btnRecallCookie_Click (...) _ Handles btnRecallCookie.Click Dim colCookies As HttpCookieCollection colCookies = Request.Cookies Dim objCookie As HttpCookie If colCookies("UserName") Is Nothing Then Label1.Text = "Cookie not yet saved" Else objCookie = colCookies("UserName") Label1.Text = objCookie.Value End If End Sub