<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
Untitled Page
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HttpCookie userCookie;
userCookie = Request.Cookies["UserID"];
if (userCookie == null)
{
myLabel.Text = "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;
}
}
}