<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="myLabel" runat="server" />
</div>
</form>
</body>
</html>
File: Default.aspx.vb
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
Dim userCookie As HttpCookie
userCookie = Request.Cookies("UserID")
If userCookie Is Nothing Then
myLabel.Text = "Cookie doesn't exist! Creating a cookie now."
userCookie = New HttpCookie("UserID", "JoeBlack")
userCookie.Expires = DateTime.Now.AddMonths(1)
Response.Cookies.Add(userCookie)
Else
myLabel.Text = "Welcome back, " & userCookie.Value
End If
End Sub
End Class
|