复制代码 代码如下:
'----------------------------------------------------------------
' Name: WriteCookie(ByVal strCookieName As String, ByVal strKeyName As String, ByVal strKeyValue As String)
' Parameters:
' [ByVal] strCookieName - cookie名字
' [ByVal] strKeyName - 键名字
' [ByVal] strKeyValue - 键值。
' Return: String
'----------------------------------------------------------------
Public Function WriteCookie(ByVal strCookieName As String, ByVal strKeyName As String, ByVal strKeyValue As String) As String
Dim objEnc As System.Text.Encoding = System.Text.Encoding.GetEncoding("GB2312")
strKeyValue = System.Web.HttpUtility.UrlEncode(strKeyValue, objEnc)
System.Web.HttpContext.Current.Response.Cookies(strCookieName)(strKeyName) = strKeyValue
End Function
复制代码 代码如下:
Sub CleanCookies()
Dim i As Integer
Dim cookie As System.Web.HttpCookie
For i = 0 To System.Web.HttpContext.Current.Request.Cookies.Count - 1
cookie = System.Web.HttpContext.Current.Request.Cookies(i)
System.Web.HttpContext.Current.Response.Cookies(CStr(cookie.Name)).Value = ""
System.Web.HttpContext.Current.Response.Cookies(CStr(cookie.Name)).Expires = DateAdd(DateInterval.Day, -1, Now)
Next
End Sub
新闻热点
疑难解答
图片精选