testCookies.asp
' 檢查浏覽器是否接受Cookies.
<%
strTest = Request.QueryString("CookieTest")
If UCase(strTest) <> Ucase("true") Then
Session("__FlashCookieTest") = True
' 第一次呼叫.設置session變量.
' 用QueryString重定向.
strURL = Request.ServerVariables("script_NAME")
strQueryString = "?CookieTest=true"
Response.Redirect(strURL & strQueryString)
Response.End
Else
If Session("__FlashCookieTest") = True Then
' 已完成重定向.檢查session變量是否包含值.
strOut = "Cookies=true"
' Session變量包含值,因此浏覽器接受Cookies.
Else
strOut = "Cookies=false"
' Session變量為空,浏覽器決絕Cookies.
End If
End If
Response.Write(strOut)
' 輸出到Flash.
%>
setCookies.asp
<%
For each item in Request.QueryString
Response.Cookies(item) = Request.Querystring(item)
Next
%>
getCookies.asp
' 讀取 Cookies
<%
For each Cookie in Request.Cookies
strOut = strOut & Server.URLEncode(Cookie) & "="
strOut = strOut & Server.URLEncode(Request.Cookies(Cookie))
strOut = strOut & "&"
Next
Response.Write strOut
%>