您现在的位置: 无忧电子商务网 >> 信息学院 >> 程序开发 >> asp >> 正文

通过ASP在Flash中妙用Cookie

作者:作者:未…    信息学院来源:网络收集    点击数:    更新时间:2006-8-27 我要参与讨论

  ted).


//Frame10
If (cookies eq "true")
Set Variable: "cookietest" = "Cookies can be set"
Stop
Else
Set Variable: "cookietest" = "Cookies not allowed. Please enable."
Go to and Stop ("nocookies")
End If


In Frame 10 a different message is displayed in the status field depending on the result of the cookie
test.

If cookies are not accepted, Flash jumps to the label 'nocookies', stops there and will not accept any
input but another cookie test. In the if-condition cookies eq "true" is set in quotes as the server does
not really return the boolean values of true or false, but a string which is immediately tested as such.
Also note that the string comparison requires 'eq' instead of '='.

The 'stop' command forces Flash to wait for a click event of the 'SEND DATA' button. Sending the cookie
data to the server happens as follows:


//Frame11, Label step2
Load Variables ("/setcookies.asp?cookiename="&name&"&"&
"cookiemail="&email&"&"&"cookietelephone="&telephone, 0)


In this script, a query string containing the user entries is sent to the file ' setcookies.asp'. For the
composition of the query string, refer to the article 'Data Exchange between ASP and Flash' (German only).


//Frame19, Label step3
Load Variables ("/getcookies.asp", 0)

The data read from a cookie by ASP is loaded into the Flash file.
//Frame 28
Stop


The loaded data is displayed in the text fields after a short animation of a line.


//Frame 35, Label nocookies
stop


If the test in frame 10 determines that no cookies are allowed, the Flash time line branches to this frame
and the user has the opportunity to perform another test.

The Scripts of the ASP files
The 3 files testcookies.asp, setcookies.asp and getcookies.asp are called by Flash for the following
actions: Checking whether the browser accepts cookies (testcookies.asp), setting cookies (setcookies.asp),
reading cookies(getcookies.asp).

Checking whether the browser accepts cookies
The file testcookies.asp checks whether the browser permits cookies. The technique is the same as in the
article "Simple Browser Cookie Test" (German only). The variation of this script used here is as follows:


<%
strTest = Request.QueryString("CookieTest")
If UCase(strTest) <> Ucase("true") Then
' First call
' Set session variable
Session("__FlashCookieTest") = True
' Redirect with QueryString
strURL = Request.ServerVariables("SCRIPT_NAME")
strQueryString = "?CookieTest=true"
Response.Redirect(strURL & strQueryString)
Response.End
Else
' Redirect already happened

上一页  [1] [2] [3] [4] 下一页

在google里搜索更多通过ASP在Flash中妙用Cookie

Google
Web www.51ec.org
【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
我来说两句 对此文章发表了评论
  昵 称: *必填    ·注册用户·
  评 分: 1分 2分 3分 4分 5分     严禁发表危害国家安全、政治、黄色淫秽等内容的评论,用户需对自己在使用本网站服务过程中的行为承担法律责任。本站管理员有权保留或删除评论内容,评论内容只代表机友个人观点,与本网站立场无关。  
评 论
内 容

 
评论列表 (最新 评论仅限网友观点!)

供求信息




| 设为首页 | 加入收藏 | 关于我们 | 广告服务 | 联系方式 | 友情链接 | 版权申明