All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
SQL,Server,7.0,入门(二)_mssql学习_编程技术
ASP.NET底层架构之从浏览器到ASP.NET_.net资料_编程技术
c#,MD5加密算法的一个实例_[Asp.Net教程]
ASP.NET,利用Outlook发送邮件_[Asp.Net教程]
PHP和AJAX打造高级RSS聚合器_php资料_编程技术
asp.net在使用fckeditor,2.6版的几个问题的解决_[Asp.Net教程]
如何识别真实和自动创建的索引?_[SQL,Server教程]
PHP对文本数据库的基本操作方法_php资料_编程技术
网页制作应掌握技术:随心所欲定制页面"弹出窗口"_JavaScript技术_编程技术
[delphi语法1]Object Pascal语言编写环境
Reading number is top 10 pictures
西方气质的东方美女3
做运动的校花1
美奂绝伦的风景
Ashlynn Brooke photograph of a group2
泳装名模阿尔贝特妮写真
超强高考作文
Entered the goddess in the AD1
猫眯也疯狂
Distribution of wealth in China survey status report
Thrilling English baby
Download software ranking
少妇苏霞全本
终极变速大师Speeder3.26
网络管理员第三版
Unix video tutorial17
Tram sex maniac 2 (H) rar bag2
C语言教程TXT
matrix3
Tram sex maniac 2 (H) rar bag18
Unix video tutorial7
Detective task-the top secret prostitution files
aaa published in(发表于) 2013/12/18 7:55:13 Edit(编辑)
Asp.Net中对Cookie的基本操作_.net资料_编程技术

Asp.Net中对Cookie的基本操作_.net资料_编程技术

Asp.Net中对Cookie的基本操作_.net资料_编程技术-你的首页-uuhomepage.com

实例代码演示Asp.Net中对Cookie的基本操作。



Imports System.Web.HttpContext
Public Class CookieFramework
'写入单个Cookie
Public Shared Function WriteCookie(ByVal CookieName As String, ByVal CookieValue As String, ByVal ExpiresDate As Integer) As Boolean
Dim aCookie As New HttpCookie(CookieName)
aCookie.Value = CookieValue
aCookie.Expires = DateTime.Now.AddDays(ExpiresDate)
System.Web.HttpContext.Current.Response.Cookies.Add(aCookie)
End Function


'给Cookie集合添加子项
Public Shared Function WriteCookies(ByVal CookieName As String, ByVal CookieItem As String, ByVal ItemValue As String, ByVal ExpiresDate As Integer) As Boolean
Dim aCookie As HttpCookie
If Current.Request.Cookies(CookieName) Is Nothing Then
aCookie = New HttpCookie(CookieName)
Else
aCookie = Current.Request.Cookies(CookieName)
End If
aCookie.Values(CookieItem) = ItemValue
aCookie.Expires = DateTime.Now.AddDays(ExpiresDate)
System.Web.HttpContext.Current.Response.Cookies.Add(aCookie)
End Function
'读取单个Cookie
Public Shared Function ReadCookie(ByVal CookieName As String) As String
If Current.Request.Cookies(CookieName) Is Nothing Then
Return Nothing
Else
Return Current.Request.Cookies(CookieName).Value
End If
End Function


'读取Cookie集合中的子项内容
Public Shared Function ReadCookies(ByVal CookieName As String, ByVal CookieItem As String) As String
If Current.Request.Cookies(CookieName) Is Nothing Then
Return Nothing
Else
If Current.Request.Cookies(CookieName).Values(CookieItem) Is Nothing Then
Return Nothing
Else
Return Current.Request.Cookies(CookieName).Values(CookieItem)
End If
End If
End Function
'删除整个Cookie
Public Shared Function DeleteCookie(ByVal CookieName As String) As Boolean
Dim aCookie As New HttpCookie(CookieName)
Dim i As Integer
Dim limit As Integer = Current.Request.Cookies.Count - 1
For i = 0 To limit
aCookie = Current.Request.Cookies(i)
aCookie.Expires = DateTime.Now.AddDays(-1)
Current.Response.Cookies.Add(aCookie)
Next
End Function
'删除Cookie集合中的子项
Public Shared Function DeleteCookies(ByVal CookieName As String, ByVal ItemName As String) As Boolean
Dim aCookie As HttpCookie = Current.Request.Cookies(CookieName)
aCookie.Values.Remove(ItemName)
aCookie.Expires = DateTime.Now.AddDays(1)
Current.Response.Cookies.Add(aCookie)
End Function
End Class





添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.