1 Reply Latest reply on Jan 10, 2010 6:48 AM by kglad

    Problem with Session Variables

    ahv2010 Level 1

      Hi,

      i have written a small web CMS in PHP. The user logs in through PHP and several session variables are set.

       

      I am working on a small Flash application that gets the current session id while loading and then obtains the session variables from a php page.

       

      My problem is that although the session variable can be seen (it is being echoed on the php page as username=johndoe), in Flash I only see "undefined" where the Username should appear.

       

      Here are my scripts:

       

      The embed part where the session id is given to Flash

       

      <object classid="clsid:(blah)" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="800" height="800" id="ZoomifyHotspotViewer">
        <param name="flashvars" value="phpsessionid=<?php print session_id(); ?>">
        <param name="src" value="test.swf">
        <embed flashvars="phpsessionid=<?php print session_id(); ?>" src="test.swf" pluginspage="http://www.adobe.com/go/getflashplayer" type="application/x-shockwave-flash" width="800" height="800" name="YourSWF"></embed>
      </object>

       

      The ActionScript part:

       

      var sendInfo = new LoadVars();
      
      sendInfo.myID = _level0.phpsessionid;
      
      sendInfo.send("flash.php", sendInfo,"POST");
      
      myData = new LoadVars();
      
      myData.onLoad = function(){
      placeTheDataIntoTheRightPlace();
      };
      
      myData.load("flash.php");
      
      placeTheDataIntoTheRightPlace = function(){
      
      t_username.text = myData.username;
      
      }; 
      

       

      The php part:

       

      <?php
      //get the session id from the flash movie
      session_id($_POST['myID']);
      session_start();
      //echo the username for the session id
      echo 'username='.$_SESSION['username'];
      ?>