Problem with Flash/PHP Webstore

Hello to you all!

First post on Kirupa, so I’ll try to make it as good as possible!

I’ve been developing a webstore for my own tiny business. I’ve decided to go with Flash as the frontend and PHP/MySQL making all the stuff behind it. It all works, products are stored on MySQL, all pretty and neat… until I hit the wall of session_id (Mind you, im not a professional developer/webdesigner).

I’ve done all my code without even thinking on the user side itself… That is, when I went to try the store and it all worked it passed my mind that if another user would be on it, he would see my cart and I would see his… MAJOR mistake…

I did a search around and found that session_id would be the answer to my problems. But then I got to another problem related to this… how do I integrate it on my flash?

Currently all the logic of it is:

  1. User goes to store, loads one product section and selectes add products:

This code is then sent via AS:

loadVariables(“http://www.sanum.com.pt/addcart.php?ref="+ref+"&desc="+desc+"&price=”+price,this);

  1. addcart.php contains this:

<?php
include “common.php”;
$query=“INSERT INTO cart (ref, desc, price, user) VALUES (’$ref’,’$desc’,’$price’,’$user’)”;

$result = mysql_query($query);
?>

  1. Lets Imagine that this product is everything that the user has and he procedes to finalize his order, so he clicks the cart (which will show the product list)

Cart is called:

loadVariables(“http://www.sanum.com.pt/cart.php”,this);

Displayed via:

// Function for Cart, attaches nest movie clips with the products
nextX = 0;
nextY = 0;
alien = 70;
special = -1;
function getMembers() {
loader.removeMovieClip();
//resets variables of _x and _y locations and depth (alien)
nextX = 0;
nextY = 0;
alien = 70;
//rotates depth
alien++;
for (count=0; count<countHigh; count++) {
content_mc[“member” add count].removeMovieClip();
}

//everything loads into members MC
//loop starting, countHigh=number of entries, received through PHP
for (count=0; count&lt;countHigh; count++) {
	// Attach a member MC to the canvas
	content_mc.attachMovie("nest", "member" add count, alien++);
	// Set X and Y positions for memberclip MC
	content_mc["member" add count]._x = nextX;
	content_mc["member" add count]._y = nextY;
	//set variables, textfield values on memberclip button MC
	//on the left is path to text fields, on the right is variable received from PHP
	content_mc["member" add count].desc = this["member" add count add "desc"];
	content_mc["member" add count].ref = this["member" add count add "ref"];
	content_mc["member" add count].price = this["member" add count add "price"];
	content_mc["member" add count].userID = this["user" add count add "ID"];
	finalprice += Number(this["member" add count add "price"]);
	content_mc["member" add count].quantity = this["member" add count add "quantity"];
	//adds _y value for nextY so other MC's can be nested
	nextY += Math.round(content_mc["member" add count]._height+special);
	alien++;
}

}
getMembers();

I’m sincerely lost… Any help on applying session_id to all this would be an amazing help. I already asked some friends for some help, but none of them are PHP masters.

Mind you that im a total newbie… Anything that I left out that might be relevant for solving this problem, please dont hesitate to ask.

Thank you so much to you all in advance,

Regards,

Tiago