ASP Cookies操作的详细介绍与实例代码

2019-04-01 18:39:58于丽

info=Myname=jeff&Gender=male&Myheight=172
  如果要把Cookie中读取的所有数据,可以用下面的代码得到:

<%For each cookie in Request.Cookies
if Not cookie.HasKeys then
Response.write cookie & "=" & Request.Cookies(cookie)
Else
for each key in Request.Cookies(cookie)
Response.write cookie&"("&key&")"&"="& Request.Cookies(cookie)(key)
next
end if
next
%>


下面是具体的在页面中记录查询的记录的代码

Sub SetCookie
Dim C_DomainList,C_i
C_DomainList=Request.Cookies("jb51")("C_DomainList")
If Domain<>"" and C_DomainList<>"" then
    If not instr(C_DomainList,Domain&"|")>0 then C_DomainList=Domain&"|"&C_DomainList
End if
If Domain<>"" and C_DomainList="" then
    C_DomainList=Domain&"|"
End if
If C_DomainList<>"" then
        Response.write "<div id=C_domainlist>您关注的站点:"
        C_arrDomain = split(C_DomainList,"|")
        C_DomainList=""
        numDomain=ubound(C_arrDomain)-1
        If numDomain>4 then numDomain=4
            for C_i=0 to numDomain
            Response.write " <a href=?url="&C_arrDomain(C_i)&">"&C_arrDomain(C_i)&"</a> |"
            C_DomainList=C_DomainList&C_arrDomain(C_i)&"|"
            next
        Response.Cookies("jb51")("C_DomainList")=C_DomainList
        Response.Cookies("jb51").Expires=Date+30
        Response.write "<a href=# style=""cursor:pointer"" onClick=""clearCookie('jb51');alert('已清除记录!');"">清除记录</a></div>"
End If
End Sub

演示页面:http://tools.jb51.net/whois.asp