Esempio di utilizzo di una sessione:
Login.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
<!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="formAutenticazione" runat="server">
<div>
<asp:TextBox ID="username" runat="server"></asp:TextBox><br />
<asp:TextBox TextMode="Password" ID="password" runat="server"></asp:TextBox>
<asp:Button ID="login" OnClick="checkLogin" Text="Login" runat="server" /><br />
<asp:Label ID="autenticazione" Visible="true" runat="server"></asp:Label>
</div>
<hr />
<div>
<asp:Button ID="logout" Text="logout" OnClick="checkLogout" runat="server" />
</div>
</form>
</body>
</html>