01.
Imports
System.Web
02.
Imports
System.Collections
03.
Imports
System.Collections.Specialized
04.
Imports
System.Web.Security
05.
06.
Public
Class
myCookies
07.
Private
Shared
_Current
As
HttpContext = HttpContext.Current
08.
Private
Shared
_cookieName
As
String
=
"__myCookies__"
09.
Private
Shared
_data
As
HybridDictionary =
Nothing
10.
11.
Sub
New
()
12.
End
Sub
13.
14.
Sub
New
(
ByVal
cookieName
As
String
)
15.
_cookieName = cookieName
16.
End
Sub
17.
18.
Public
Sub
InsertValue(
ByVal
subKey
As
String
,
ByVal
subValue
As
String
)
19.
If
_Current.Response.Cookies(_cookieName) IsNot
Nothing
Then
20.
Dim
aCookie
As
HttpCookie = _Current.Response.Cookies(_cookieName)
21.
aCookie.Values.Add(subKey, subValue)
22.
Else
23.
Dim
aCookie
As
New
HttpCookie(_cookieName)
24.
aCookie.Values.Add(subKey, subValue)
25.
_Current.Response.AppendCookie(aCookie)
26.
End
If
27.
End
Sub
28.
29.
Public
Function
GetValue(
ByVal
subKey
As
String
)
As
String
30.
Dim
retValue
As
String
=
String
.Empty
31.
If
_Current.Response.Cookies(_cookieName) IsNot
Nothing
Then
32.
Dim
aCookie
As
HttpCookie = _Current.Response.Cookies(_cookieName)
33.
Try
34.
retValue = aCookie.Values(subKey)
35.
Catch
ex
As
Exception
36.
37.
End
Try
38.
End
If
39.
Return
retValue
40.
End
Function
41.
End
Class