2013-04-30 36 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#)