惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
有赞技术团队
有赞技术团队
V
Visual Studio Blog
T
The Blog of Author Tim Ferriss
爱范儿
爱范儿
Vercel News
Vercel News
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
D
DataBreaches.Net
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
大猫的无限游戏
大猫的无限游戏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
GbyAI
GbyAI
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
The Cloudflare Blog
宝玉的分享
宝玉的分享
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog

博客园 - kwame

CXX0017错误的解决办法 基础知识--is & as 的区别 - kwame 基础知识--变量和常量 - kwame - 博客园 基础知识--Boxing & unBoxing 基础知识--值类型和引用类型 用Visual C#创建Windows服务程序 (转)用C语言编写Windows服务程序的五个步骤 昨天的事今天来写也叫昨天的日记吧?? 我是个被窥视狂? 一个馒头和一个*六*合*彩*网站引发的血案 *六*合*彩*网站也能做成这样不容易呀! 取得一段汉语的每个字的首字母 网页效果集合(小技巧) Oracle中隐式游标和显式游标的教训[同事的经历] C#.net word 受控编程系列1-向word中插入图片 安装和部署企业程序库(Installation and Deployment of Enterprise Library) OA需要分析3 OA需求分析2 OA需求分析1
写入、读取 cookie 无聊顺便复习了下前面学的东西!
kwame · 2006-03-01 · via 博客园 - kwame

转自:http://www.cnblogs.com/thcjp/archive/2006/03/01/340323.html

<%@ Page Language="VB" %>
<!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>
<script language="vb" runat="server">
'写入cookie
sub writcooks_click(sender as object,e as eventargs)
'定义并创建名为cookieexmp的cookie对象
 dim newcookie as httpcookie = new httpcookie("cookieexmp")
 dim thc as string = cstr(txtname.text)
 dim nnv as string = cstr(sex.selecteditem.text)
'添名为 name ,值为 thc 的子键。后两条语句作用与其内似。
 newcookie.values("name") =thc
 newcookie.values("sex")=nnv
 newcookie.values("dj") = "5"
 newcookie.values("dt") = datetime.now.date()
 newcookie.expires = datetime.now.adddays(10) '这句是做什么的,我不知道,有知道的麻烦告诉我下,谢谢!
 response.cookies.add(newcookie) ' 写入cookie对象
 response.Write("<h1>写入完成</h1><p><p>")
end sub
'读取cookie
sub tbn_click(sender as object, e as eventargs)
'由request对象获取cookieexmp
dim getcookie as httpcookie = request.Cookies("cookieexmp")
response.Write("<h2>以下是读出来的东西</h2><hr><br>")
response.Write("名称:" & getcookie.values("name") & "<br>")
response.Write("性别:" & getcookie.values("sex") & "<br>")
response.Write("会员等级:" & getcookie.values("dj") & "<br>")
response.Write("时间:" & getcookie.values("dt") & "<br>")
end sub
'用户名框动作
sub w_name(sender as object,e as eventargs)
lbl.text="用户名" & txtname.text & "正确,请继续输入"
end sub
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<form runat="server">
  <p>请输入用户名:
    <asp:TextBox ID="txtname" AutoPostBack="true" TextMode="SingleLine" runat="server" OnTextChanged="w_name" />  &nbsp;&nbsp;
  <asp:Label ID="lbl" runat="server"/></p>
请选择性别:
<asp:RadioButtonList ID="sex" runat="server" RepeatDirection="Horizontal">
<asp:ListItem>男</asp:ListItem>
<asp:ListItem>女</asp:ListItem>
</asp:RadioButtonList>
  <p>
    <asp:Button ID="writcooks" Text="写入cookie" runat="server" OnClick="writcooks_click"/>     
    <asp:Button ID="tbn" Text="读取cookie" runat="server" OnClick="tbn_click"/>     
</p>
</form>
</body>
</html>