3 Replies Latest reply on Aug 2, 2008 8:37 AM by katychapman85

    Flex 3 and PHP Sessions

      I am using PHP with my Flex application and I'm trying to create a Shopping Cart. I've got a PHP Session for the contents of the Shopping Cart and I tried sending the Shopping Basket data back in XML. However it works if I'm on the XML/PHP page but not in the Flex application.

      Here is my PHP file that produces the XML:
      header ("Content-type: text/xml");
      echo '<?xml version = "1.0"?>';
      if (!isset($_SESSION['ShoppingBasket']))
      $_SESSION['ShoppingBasket'] = array();

      if ((isset($_GET['BuyPalette'])) && (isset($_GET['NoOfPalettes'])))
      $_SESSION['ShoppingBasket'][] = array(
      "PaletteNo" => $_GET['BuyPalette'],
      "NoOfPalettes" => $_GET['NoOfPalettes']

      $NoOfItems = count($_SESSION['ShoppingBasket']);
      $Return = "<ShoppingBasket><NoOfItems Total='$NoOfItems'/></ShoppingBasket>";
      print ($Return);

      This is my Add to Basket function in ActionScript:
      public function AddToBasket():void{
      document.ShoppingBasketItems.url = " http://localhost/Flex/Personalised%20Palettes-debug/Header.php?BuyPalette=";
      document.ShoppingBasketItems.url = PaletteNumber;
      document.ShoppingBasketItems.url = "&NoOfPalettes=";
      document.ShoppingBasketItems.url = NumberOfPalettes;

      And this is the label I want to update:
      <mx:Repeater id="ShoppingBasketRepeater" dataProvider="{ShoppingBasketItems.lastResult.NoOfItems}" startingIndex="0">
      <mx:Label x="640" y="13" text="Your Shopping Basket Contains {ShoppingBasketRepeater.currentItem.@Total} Item(s)" color="#FFFFFF" id="ShoppingBasketLabel"/>

      Is there a special way for handing PHP sessions in a Flex application?