In asp, we can use the response.cookies method to define the value of cookies. Here's how:
response.cookies(cookiesname)[(key)|.attribute]=value
The explanation is as follows: cookiesname is the name of the cookie you want, such as: test
Parameter key: Optional parameter, of course, you can also not specify it. :)
The key is used to specify the name of the cookie for the dictionary cookie. My understanding seems to be similar to an array.
The parameter attribute is optional and specifies information related to the cookie itself, such as specifying a specific URL, path, validity period, etc.
Optional values are: Domain can only read cookies of a specific domain name
Expires cookie validity period
Does Haskeys contain child cookies?
Path can only read cookies on the specified path
Secure specifies whether the cookie is encrypted
For example, to specify a cookie named jb51 on this website, the method is as follows:
Copy the code code as follows:
Response.Cookies(jb51).Domain = www.xxx.com 'Specify www.xxx.com to visit
Response.Cookies(jb51).Path = E-Blog 'Specify E-Blog directory access
Response.Cookies(jb51).Expires= DateAdd(d,2,date) 'Expires after specified two days
Response.Cookies(jb51)(name)=Test
Response.Cookies(jb51)(type)=haha
[html]
The above two sentences create a dictionary-style cookie.
Regarding the usage of Haskeys, it is quite simple. Just request.Cookies(cookie).Haskeys. For example, if you want to determine whether a cookie is dictionary style, you can write it as
[code]
<%
If Request.Cookies(jb51).Haskeys Then
Response.Write This is a dictionary cookie
Else
Response.Write This is not a dictionary cookie
End If
%>