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