<%@ language="c#" %> 
<HTML> 
<script  runat="server">
private void btsubmit_Click(object sender, System.EventArgs e)
{
	//创建一个新Cookie，其cookie名来自于NameField.Text    
	HttpCookie MyCookie = new HttpCookie(NameField.Text);
	DateTime  now = DateTime.Now;
	//设定Cookie的值 
	MyCookie.Value = ValueField.Text;
	//设定cookie生命
	MyCookie.Expires = now.AddHours(1);
	//添加Cookie 
	Response.Cookies.Add(MyCookie);
	//给用户提示
	Response.Write("Cookie写入成功<br><hr>");
} 
</script> 
<body> 
<h3> 
利用Response对象把cookie值写入客户的计算机测试
</h3> 
<form runat="server" ID="Form1"> 
Cookie名称：<asp:textbox id="NameField" runat="server" /> <br> 
Cookie值： <asp:textbox id="ValueField" runat="server" /> <br> 
<asp:button text="写入" onclick="btsubmit_Click" runat="server" ID="Button1" /> <br> 
</form> 
</body> 
</HTML>
