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