I am trying to use a visitors session id as a temporary ID for a order. I am specifying the order id like this:

But it is coming up blank. Can anyone tell me how to use the users session id as a temporary orderid? Also if the user visits my site today and places an order and the visitors session id is used as the temporary order id, then they visit my site again a week later and place another order would the visitors session id for the second time they visit my site a week later be the same as the first time they visited my site and placed an order?

Thanks in advance all.

make sure you have session_start() on the first line of the file and change to:

$orderID = $_SESSION['sessionID'];

Oh…the session ID would be different the next time.

Ok I do have sessions start when a user logs in but i don’t specify session_start() when a user logs In i register thier session in the following manner:

            $a1 = mysql_fetch_array($r1);

$_SESSION[UserID] = $a1[‘UserID’];

If I use session_start() would I have to use it on every page? Also how would I put that session into a variable and would the users session be the same on the second visit if they purchase anything??

you need session_start() on each page you set or use the session variable. The sessionID will be different each time they access your site regardless if they purchase or not.

Ok but if I use what you said the session start will that void out my other sessions i have set up from when the user logs in? By the way Thank you for the help…

the session ID will be the same until the user logs off and closes their browser or you kill the session with session_destroy()

Ok I do kill the session with session destroy when they log out. So even after the user logs in thru the log in page when they go the the payment page on the payment page I can use session start and then take the session id and enter it into the database and from there carry the session id in a variable so i do not have to use the session start on every page there after, right???

yes, you only need session_start() if you are going to use/set a session variable

Thank you for all the help. I am going to try it now. Originally I set it up with the temp order id as the users id. The problem I ran into was when the first transaction is made the user can no longer make another transaction due to the fact that thru the merchant account when that user would go to make another transaction the order id which i had set to the user id comes back as duplicate order id from the merchant account becuase the users id never changes and it is already an order number from the first transaction in the merchant account. So if the sessions will always be different I shouldn’t have that problem if this works. Thank you much for the help. I will let you know how I make out.

your welcome, I think you may have a better chance hitting power ball than getting the same sessionID

I am sorry but I am confused. Should I play a few bucks… and give up on the site?? lol

it depends how lucky you feel!!!

I get an error message :
Parse error: parse error, unexpected T_VARIABLE in /home/content/a/l/p/tristar/html/payment.php on line 42

line 41&42:
$PHPSESSID = $_SESSION[‘sessionID’];

I put that just before an insert query for the database is that ok? Or does it have to be at the top of the script?
I used the $PHPSESSID variable due to the fact that then I wont have to change 6 other pages… LOL

session_start() should be at the start->


you can set variable anywhere befor you use it.

That is what I thought. TY again… =)

Ok it is coming up blank for the order id…

$_SESSION[‘sessionID’]; that should pull the session id right?

echo $_SESSION[‘sessionID’];

I edit my post I got it working but now it isnt registering the sessionID… Any idea why? The order id in the database is empty here is my code:

error_reporting(E_ALL & ~E_NOTICE);



        //get the price details
        $q2 = "select * from tvin_prices, tvin_priority where tvin_prices.PriceID = '$_GET[SelectedPackage]' and tvin_prices.PriorityLevel = tvin_priority.PriorityLevel ";
        $r2 = mysql_query($q2) or die(mysql_error());
        $a2 = mysql_fetch_array($r2);

        //get the agent details
        $q1 = "select * from tvin_users where UserID = '$_SESSION[UserID]' ";
        $r1 = mysql_query($q1) or die(mysql_error());
        $a1 = mysql_fetch_array($r1);

        if($_GET[PaymentGateway] == "creditcard")

$PHPSESSID = $_SESSION['sessionID'];

        $q1 = "insert into tvin_orders_content set
                                        OrderID = '$PHPSESSID',
                                        UserID = '$_SESSION[UserID]',
                                        PriceID = '$a2[PriceID]',
                                        PriceType = '$a2[PriceType]',
                                        PackageName = '$a2[PackageName]',
                                        PriceValue = '$a2[PriceValue]',
                                        PriorityLevel = '$a2[PriorityLevel]',
                                        PriceTotal = '$a2[PriceValue]' ";
        mysql_query($q1) or die(mysql_error());