网络编程
位置:首页>> 网络编程>> Asp编程>> ASP状态封装类Cache、Cookie & Session(2)

ASP状态封装类Cache、Cookie & Session(2)

作者:Movoin 来源:Movoin ^ Blog 发布时间:2008-05-11 19:33:00 

标签:缓存,cache,cookie,session,asp

CookieState类,建议实例化时用名Cookie

程序代码

<%
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
%>

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com