Setting expire date and path for cookies in ASP.NET (VHB.net) : Cookie « Session Cookie « ASP.Net






Setting expire date and path for cookies in ASP.NET (VHB.net)

<%@ Page Language="vb" %>
<html>
   <head>
      <title>Setting cookies in ASP.NET</title>
   </head>
<body>

<p>

<%
    Dim Cookie1 As New HttpCookie("Cookie1")
    Dim Cookie2 As New HttpCookie("Cookie2")
    Dim ExpiryDate As DateTime = DateTime.Now()
    ExpiryDate = ExpiryDate.AddHours(1)
    
    Cookie1.Value = "Cookie from java2s.com"
    Cookie1.Expires = ExpiryDate
    Cookie1.Path = "/"
    
    Cookie2.Values("V1") = "1"
    Cookie2.Values("V2") = "2"
    Cookie2.Values("V3") = "3"
    Cookie2.Expires = ExpiryDate
    Cookie2.Path = "/"
    
    Response.Cookies.Add(Cookie1)
    Response.Cookies.Add(Cookie2)
    Response.Write("Cookies written")

%>

</p>

</body>
</html>
           
       








Related examples in the same category

1.Create and retrieve Cookie data (C#)
2.Display all Cookie (C#)
3.Delete Cookie (C#)
4.Delete All Cookies (C#)
5.Setting a Cookie (VB.net)
6.Adding cache dependencies (VB.net)
7.Getting cookie values in ASP.NET
8.Write Cookie and read Cookie (VB.net)
9.Save and retrieve values in Cookie (C#)
10.Save Cookie (Vb.net)
11.Set cookie expire date (VB.net)