' Check whether the session variable contains the value
If Session("__FlashCookieTest") = True Then
' Session variable contains value
' Thus browser accepts cookies
strOut = "Cookies=true"
Else
' Session variable is empty
' Thus browser does not accept cookies
strOut = "Cookies=false"
End If
End If
' Output to Flash:
Response.Write(strOut)
%>
Simply put, the script sets a session variable, performs a redirect onto itself and then checks whether
the value still is set in the session variable. For this value to stay saved, the browser must have
accepted the session cookie of the Internet Information Server (IIS) which is automatically sent to the
browser by ASP. This means that the browser accepts cookies when the value in the session variable is
still present after a redirect.
The file returns the text 'Cookies=true' if the browser accepts cookies or 'Cookies=false' if the browser
does not accept cookies.
When Flash calls the file testcookies.asp via the Flash command Load Variables, the ASP file returns
either the string "Cookies=true" or "Cookies=false" to the Flash file which automatically sets the
variable Cookies to "true" or "false" in Flash.
Setting Cookies
In ASP, cookies can be set easily using the Response.Cookies collection. In our example, the Flash file
calls the file setcookies.asp and passes the variables for the cookies (names and values) in the
Querystring to the ASP Script.
The ASP Script reads all values out of the Querystring collection sends the corresponding cookies via
Response.Cookies to the browser. The complete ASP script consists of only three lines:
<%
For each item in Request.QueryString
Response.Cookies(item) = Request.Querystring(item)
Next
%>
Reading Cookies
Reading the cookies and writing them to the Flash File is about as easy as setting the cookies. When the
Flash file calls the file getcookies.asp, it returns all the names and values of the cookies as URL-
encoded text. This way, the values of the cookes are written to variables of the same names in Flash when
Flash calls the filegetcookies.asp.
The ASP file getcookies.asp is as follows:
<%
For each cookie in Request.Cookies
strOut = strOut & Server.URLEncode(cookie) & "="
strOut = strOut & Server.URLEncode(Request.Cookies(cookie))
strOut = strOut & "&"
Next
Response.Write strOut
%>
Conclusion
The Flash based part of this article was created using Flash 4. The systematics are the same for the newly
published Version 5 of the Macromedia software.
The ASP part runs on IIS 4.0 as well as on IIS 5.0 and with slight modifications also under ASP+.
After having described setting and reading of coo
If Session("__FlashCookieTest") = True Then
' Session variable contains value
' Thus browser accepts cookies
strOut = "Cookies=true"
Else
' Session variable is empty
' Thus browser does not accept cookies
strOut = "Cookies=false"
End If
End If
' Output to Flash:
Response.Write(strOut)
%>
Simply put, the script sets a session variable, performs a redirect onto itself and then checks whether
the value still is set in the session variable. For this value to stay saved, the browser must have
accepted the session cookie of the Internet Information Server (IIS) which is automatically sent to the
browser by ASP. This means that the browser accepts cookies when the value in the session variable is
still present after a redirect.
The file returns the text 'Cookies=true' if the browser accepts cookies or 'Cookies=false' if the browser
does not accept cookies.
When Flash calls the file testcookies.asp via the Flash command Load Variables, the ASP file returns
either the string "Cookies=true" or "Cookies=false" to the Flash file which automatically sets the
variable Cookies to "true" or "false" in Flash.
Setting Cookies
In ASP, cookies can be set easily using the Response.Cookies collection. In our example, the Flash file
calls the file setcookies.asp and passes the variables for the cookies (names and values) in the
Querystring to the ASP Script.
The ASP Script reads all values out of the Querystring collection sends the corresponding cookies via
Response.Cookies to the browser. The complete ASP script consists of only three lines:
<%
For each item in Request.QueryString
Response.Cookies(item) = Request.Querystring(item)
Next
%>
Reading Cookies
Reading the cookies and writing them to the Flash File is about as easy as setting the cookies. When the
Flash file calls the file getcookies.asp, it returns all the names and values of the cookies as URL-
encoded text. This way, the values of the cookes are written to variables of the same names in Flash when
Flash calls the filegetcookies.asp.
The ASP file getcookies.asp is as follows:
<%
For each cookie in Request.Cookies
strOut = strOut & Server.URLEncode(cookie) & "="
strOut = strOut & Server.URLEncode(Request.Cookies(cookie))
strOut = strOut & "&"
Next
Response.Write strOut
%>
Conclusion
The Flash based part of this article was created using Flash 4. The systematics are the same for the newly
published Version 5 of the Macromedia software.
The ASP part runs on IIS 4.0 as well as on IIS 5.0 and with slight modifications also under ASP+.
After having described setting and reading of coo
| 对此文章发表了评论 |
