加入收藏 | 设为首页 | 会员中心 | 我要投稿 南平站长网 (https://www.0599zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

Cookie,Session,Application封装 - ASP教程

发布时间:2016-08-11 01:11:55 所属栏目:Asp教程 来源:站长网
导读:再把其它的操作,比如Cookie,Session,Application封装 CookieState类: % Class CookieState Private CurrentKey Public Default Property Get Contents(ByVa
再把其它的操作,比如Cookie,Session,Application封装

CookieState类:

<%
Class CookieState

Private CurrentKey

Public Default Property Get Contents(ByVal Value)
Contents = Values(Value)
End Property

Public Property Let Expires(ByVal Value)
Response.Cookies(CurrentKey).Expires = DateAdd("d", Value, Now)
End Property
Public Property Get Expires()
Expires = Request.Cookies(CurrentKey).Expires
End Property

Public Property Let Path(ByVal Value)
Response.Cookies(CurrentKey).Path = Value
End Property
Public Property Get Path()
Path = Request.Cookies(CurrentKey).Path
End Property

Public Property Let Domain(ByVal Value)
Response.Cookies(CurrentKey).Domain = Value
End Property
Public Property Get Domain()
Domain = Request.Cookies(CurrentKey).Domain
End Property

Public Sub Add(ByVal Key, ByVal Value, ByVal Options)
Response.Cookies(Key) = Value
CurrentKey = Key
If Not (IsNull(Options) Or IsEmpty(Options) Or Options = "") Then
If IsArray(Options) Then
Dim l : l = UBound(Options)
Expire = Options(0)
If l = 1 Then Path = Options(1)
If l = 2 Then Domain = Options(2)
Else
Expire = Options
End If
End If
End Sub

Public Sub Remove(ByVal Key)
CurrentKey = Key
Expires = -1000
End Sub

Public Sub RemoveAll()
Clear()
End Sub

Public Sub Clear()
Dim iCookie
For Each iCookie In Request.Cookies
Response.Cookies(iCookie).Expires = FormatDateTime(Now)
Next
End Sub

Public Function Values(ByVal Key)
Values = Request.Cookies(Key)
End Function

Private Sub Class_initialize()
End Sub
Private Sub Class_Terminate()
End Sub

End Class
%>

(编辑:南平站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读