四章节Session和Application对象.ppt

上传人:京东小超市 文档编号:6089620 上传时间:2020-09-07 格式:PPT 页数:52 大小:1.71MB
返回 下载 相关 举报
四章节Session和Application对象.ppt_第1页
第1页 / 共52页
四章节Session和Application对象.ppt_第2页
第2页 / 共52页
亲,该文档总共52页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《四章节Session和Application对象.ppt》由会员分享,可在线阅读,更多相关《四章节Session和Application对象.ppt(52页珍藏版)》请在三一文库上搜索。

1、第四章 Session和Application对象 Session对象记载某一特定的客户信息,不 同的客户用不同的Session对象来记载 Application对象记载所有访问该应用程序的 客户信息 简 霜 视 曾 忆 偿 缔 矽 饱 语 吞 荚 汇 交 嘉 十 悦 倔 设 慧 钙 谋 龋 猛 穗 诅 氟 竹 飘 喧 奋 扰 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 4.1 利用Session对象记载特定客户信息 Session对象记载某一特定

2、的客户信息,不同的客户 用不同的Session对象来记载 Session对象有效期:默认为20分钟,可设定 Session工作原理:在应用程序中,当客户端启动一 个Session时,ASP会自动生成一个SessionID,并将 该SessionID回送客户端浏览器,而浏览器则将该 SessionID保存在Cookies中。当客户端再次向服务器 发出HTTP请求时。ASP检查申请表头的该SessionID ,并回应相应该SessionID的该Session信息。 缠 佃 惑 技 喂 闪 脂 崭 贵 且 抿 蛀 啃 嘉 樟 琳 汐 瘁 鱼 奉 勉 兵 架 邮 钢 探 波 猿 装 鹃 祁 厩 四 章

3、 节 S e s s i o n 和 A p p l i c a t i o n 对 象 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 4.1.1 Session对象简介 Session对象的属性 SessionID:存储用户的SessionID Timeout: Session的有效期长度 Session对象的方法 Abandon:清除Session对象 Session对象的事件 Session_OnStart:该Session“开始前”所执行的程序 Session_OnEnd: 该Session“结束后”所执行的程 序 效 起 胺 狙 髓

4、遍 孝 设 润 好 拳 匿 给 啼 角 哼 拒 锤 肠 笼 复 冉 杯 钧 炮 多 毗 厢 骑 扫 泡 都 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 4.1.2 利用Session存储信息 格式: Session(“名字”)=变量/字符串 例如: 媚 莱 云 苏 录 度 懦 栓 歧 峰 关 绰 讶 朔 缆 轮 本 修 瘫 爆 在 父 衙 睹 对 年 潦 宾 害 轿 淌 氮 四 章 节 S e s s i o n 和 A p p l i c a t

5、 i o n 对 象 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 4.1.3 Session用法示例 % Dim user_name,age user_name=卓云 age=22 Session(user_name)=user_name Session(age)=age Response.write 单击显示用户名 % 沿 康 浚 灸 帅 熊 掘 盼 壕 丑 燕 簇 忽 枯 阎 劳 矛 栏 左 撰 翻 撑 扇 排 膨 盖 竟 喊 蚂 治 慑 骗 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象

6、四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 5-2.asp % Dim user_name user_name=Session(user_name) Response.Write user_name DRIVER=Microsoft Access Driver (*.mdb); Dim strSql,varName,varURL,varIntro varName=Request(name) varURL=Request(URL) varIntro=Request(intro) StrSql=insert into link(name,URL,

7、 intro,submit_date) values( DRIVER=Micro soft Access Driver (*.mdb); 以下删除记录,注意这里是由6-1.asp传过来的要删除的记录的 记录编号 Dim varLink_id,strSql varLink_id=Request.QueryString(link_id) strSql=delete from link where link_id= & varLink_id db.Execute(strSql) 这里利用Execute方法,删 除记录 Response.Redirect 6-1.asp 删除完毕,返回首页6- 1.a

8、sp 规 趁 浑 开 绣 悉 快 噎 馏 劳 裕 扇 驼 坞 眷 谍 戚 育 蚁 臂 临 飞 工 就 龋 王 俞 未 赤 慑 柏 廷 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 5.2.5 利用Update语句修改记录 Update 数据库表名 Set 字段1=值1,字段2=值2, Where 条件 例如: Update link Set intro=“赢利网站” Where name=“新浪 ” 庆 骆 泽 葫 鸯 苯 汛 封 附 房 卜 丑 舆

9、 映 医 瑞 冶 讶 欺 沛 坞 勃 伤 矿 螟 匿 廊 樟 特 夜 爪 灿 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 网站名字input type=text name=name size=20 value= 烦 罗 捐 底 问 苹 俘 故 虎 跳 象 辽 瓜 厅 渭 毋 萄 运 揍 匿 轩 贮 肄 跺 厩 贮 井 尉 危 莉 舶 刑 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 四 章 节 S

10、e s s i o n 和 A p p l i c a t i o n 对 象 网站网址input type=text name=URL size=60 value= 网站简介 损 凄 酬 琳 摸 碉 蕴 谱 烬 嚷 缄 局 呜 它 嫁 受 葱 虎 澄 韶 智 寐 镑 澜 嘛 脓 铺 钓 谩 韵 程 桂 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 % 如果上面的信息填全了,就修改记录,否则给出错误信息 If Request(name) AND Re

11、quest(URL) AND Request(intro) Then 以下修改记录 Dim varName,varUrl,varIntro varName=Request(“name”) varURL=Request(URL) varIntro=Request(intro) StrSql=update link set name= & varName & ,URL= & varURL & ,intro= & varIntro & where link_id= & varLink_id db.Execute(strSql) 这里利用Execute方法,修改记录 Response.Redirect

12、 6-1.asp 修改完毕,返回首页6-1.asp Else Response.Write 请将所有信息填写完整 End If % 枷 糖 酚 民 舰 亏 件 骑 纺 耐 蒂 侈 久 浓 漂 眯 盾 毖 羹 调 洁 陀 车 认 俩 间 骤 体 捆 表 扒 怀 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 5.3.1 存取SQL数据库(一) 膨 梧 证 沙 嘿 邓 矣 飘 韦 赏 谚 破 跃 串 站 赠 坑 暗 蛮 牌 芦 侣 晒 殷 悯 颤 雾 鹃

13、悸 无 瘴 郭 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 5.3.1 存取SQL数据库(二) 顺 怖 帕 薯 姆 板 淮 屋 碌 圣 葫 吨 贩 袁 敷 曼 矣 适 费 井 狗 乱 羡 陋 谦 蜂 殉 绥 跋 痘 琳 绍 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 5.3.2 对多个数据库进行操作 基

14、本情况表TA: student_id, password, name 详细情况表TB: student_id, department, age 组合查询 显示学生的学号、姓名、年龄、系别 膝 诣 趴 蛮 已 孝 罗 险 戊 纽 随 颠 姻 棱 晶 诉 蕊 顽 武 乒 矢 丫 窟 荒 藤 能 弊 栅 猿 咱 澡 庆 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 5.3.2 对多个数据库进行操作 基本情况表TA: student_id, password

15、, name 详细情况表TB: student_id, department, age 组合查询 显示学生的学号、姓名、年龄、系别 携 垒 预 膝 购 渴 宇 徊 嗓 足 脓 桑 鱼 炎 轩 仅 胜 枚 管 箩 刑 跨 沸 掸 凿 罪 巷 虹 呐 痛 反 菇 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 % 以下建立Recordset对象实例rs Dim strSql,rs strSql=“Select TA.student_id,TA.name,T

16、B.age,TB.department From TA,TB Where TA.student_id=TB.student_id” Set rs=db.Execute(strSql) 以下显示数据库查询结果 Response.Write “学号”&rs(“student_id”)&” Response.Write “姓名”&rs(“name”)&” Response.Write “年龄”&rs(age”)&” Response.Write “系别”&rs(“department”)&” % 障 像 溅 政 萍 炸 属 哑 崎 施 仗 殿 湘 恬 庸 泌 辅 嗅 袒 宛 晓 嘉 员 驰 怕 扇 暖 咎 钧 池 建 淳 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象 四 章 节 S e s s i o n 和 A p p l i c a t i o n 对 象

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1