Save value to cookie and read them back (VB) : Write « Cookie « ASP.NET Tutorial






<%@ Page Language="VB" %>

<script runat="server">
   sub Page_Load(Sender as Object, e as EventArgs) 
      dim strVariable as string
      
      'set up some cookie variables 
      Response.Cookies("temp").Value = "HI"
      Response.Cookies("myCookie")("Username") = "Chris"
      Response.Cookies("myCookie")("Preference") = "800x640"
      Response.Cookies("myCookie")("Password") = "CookiesRock"
      Response.Cookies("myCookie")("LastVisit") = DateTime.Now.ToString
      Response.Cookies("myCookie")("UserAgent") = Request.ServerVariables("HTTP_USER_AGENT")
     
      for each strVariable in Response.Cookies("myCookie").Values
         Label1.Text += "<b>" & strVariable & "</b>: " & _
            Request.Cookies("myCookie")(strVariable) & "<br>"
      next
   end sub
</script>

<html><body>
   <form runat="server">
      <asp:Label id="Label1" runat="server"/>
   </form>
</body></html>








12.6.Write
12.6.1.Save value to cookie and read them back (VB)