2013-04-30 40 views
0

我有嵌入在HTML文件中的SWF:如何防止swf创建自己的会话ID?

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> 
<head> 
     <title>v2</title> 
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
     <style type="text/css" media="screen"> 
     html, body { height:100%; background-color: #ffffff;} 
     body { margin:0; padding:0; overflow:hidden; } 
     <!--#wrapper { width:100%; height:100%;} 
     #flashContent { width:100%; height:100%; margin-right:auto; margin-left:auto; text-align:center;}--> 

     </style> 
    <script language="javascript">AC_FL_RunContent = 0; 
     </script> 
    <script src="/AC_RunActiveContent.js" language="javascript"></script> 
    <script language="javascript"> 
     function backfunc(arg){ 
      window.location.replace(arg); 
     } 
    </script> 
<head> 
<body> 

    <script language="javascript"> 
    var flashpath = '{{song.flashURL}}' + '?date=' + new Date().getTime(); 
    var songId = {{song.id}}; 
    var vars = 'username={{current_user.first_name}} {{current_user.last_name}}' + '&' + 
       'songid={{song.id}}' + '&' + 
       'sessionid={{session_id}}'; 
    if (AC_FL_RunContent == 0) { 
     alert("This page requires AC_RunActiveContent.js."); 
    } else { 

     AC_FL_RunContent(
      'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=11,0,0,0', 
      'width', '640', 
      'height', '480', 
      'src', flashpath, 
      'quality', 'high', 
      'pluginspage', 'http://www.macromedia.com/go/getflashplayer', 
      'align', 'middle', 
      'play', 'true', 
      'loop', 'false', 
      'scale', 'default', 
      'wmode', 'window', 
      'flashVars',vars, 
      'devicefont', 'false', 
      'id', '{{song.flashURL}}', 
      'bgcolor', '#ffffff', 
      'name', '{{song.flashURL}}', 
      'menu', 'true', 
      'allowFullScreen', 'true', 
      'allowScriptAccess','sameDomain', 
      'movie', flashpath, 
      'salign', '' 
      ); //end AC code 
    } 
</script> 
</body> 
</html> 

我在我的SWF一个按钮,调用javascript函数的页面重定向到主页。 AS3和JS代码的优势如下: AS3:

if(ExternalInterface.available){ 
    txt.text = url; 
    ExternalInterface.call("backfunc",url); 
} 
else{ 
    txt.text = "ex int not available"; 
} 

JS:

function backfunc(arg){ 
    window.location.replace(arg); 
} 

当我做此操作时,会出现问题。问题是,当主页加载时,我看到了旧的注销用户的页面,因为Flash会保留旧的和死的会话ID。因此,由于swf,我无法仅管理浏览器和服务器之间的会话。我该如何解决这个问题。我一直在谷歌和这里搜索2周,最后我决定写在这里。提前致谢。

+1

我不认为Flash知道会话的任何内容。 – 2013-04-30 16:14:06

回答

0

我终于解决了这个问题。问题在于域名。当用户从www.site.com进入网站时,浏览器会创建一个会话。在我们的服务器代码中,重定向是作为site.com/blabla进行的。由于缺少“www”,浏览器会创建一个新的会话,并出现问题。我通过使用相对路径解决了这个问题。

0

Definetly问题不闪光有关。会话是服务器端,我无法看到你的页面中的任何服务器脚本。 (如PHP或C#)