afan@xxxxxxxx wrote: > I'll try to explain my problem as better as I can. Please, be "gentle" :) > > I developed a program for our salespeople (only them, no public) where > they can order items for their customers. Order form is made of 6 pages > (order info, items info, artwork, ad copies,...). Also, they use the same > program to manipulate saved/submitted orders, send confirmation to > customers, requests to suppliers,... Code works fine. But this morning I > found a bug that if Salesperson open 2nd window in this program, since it > has the same session id, it would make a mess with session. I.e., on 1st > window I'm doing an order. Order ID, customer ID, transaction ID are > stored in session table. In the middle of the order I open 2nd window to > check a price on an other customer order. After I opened that order "new" > order ID and customer ID are stored now in session table and the order > (1st window) is now broken or goes to wrong place. > Or, I'm sending request for approval of an order to customer. But, second > before I submit the request, I open an order of other customer. Other > customer ID is now stored in session table and conf. email goes to wrong > place. > There are few more scenarios of "bug make mess". > > Did anybody had a problem with "2nd window" and how is it solved? What's > wrong with structure/idea I used to make a program? the problem is not '2nd Window' but rather that you are using the session id to uniquely indentify an order [manipulation] process/transaction (which consists of multiple http requests) ... a very crude idea below (you have to add a request variable named 'ordertransid' in all links pointing to pages that have to act on an existing order transaction, leaving it out would generate a new order transaction (on the relevant page[s]) for which you can then use the newly appointed transaction id to point subsequent pages to the transaction that was just created: function getOrderTransactionData() { if (!$_SESSION['ordertransstack']) { $_SESSION['ordertransstack'] = array(); } $transid = @$_REQUEST['ordertransid']; if (!$transid || !isset($_SESSION['ordertransstack'][$transid])) { $transid = count($_SESSION['ordertransstack']); $_SESSION['ordertransstack'][$transid] = initNewOrderTransactionData(); } else { $data = $_SESSION['ordertransstack'][$transid]; } return array('ordertransid' => $transid, 'data' => $_SESSION['ordertransstack'][$transid]); } function setOrderTransactionData($data) { if (!$_SESSION['ordertransstack']) { $_SESSION['ordertransstack'] = array(); } $transid = @$_REQUEST['ordertransid']; if ($transid && isset($_SESSION['ordertransstack'][$transid])) { $_SESSION['ordertransstack'][$transid] = $data; return true; } return false; } function deleteOrderTransaction() { $transid = @$_REQUEST['ordertransid']; if ($transid && isset($_SESSION['ordertransstack'][$transid])) { unset($_SESSION['ordertransstack'][$transid]); return true; } return false; } list($orderTransId, $orderTransData) = getOrderTransactionData(); on rereading your post - your storing session data in a db, why bother; secondly it sounds like you just overwriting the session record with a new transaction id rather than adding a new transaction id [record] and leaving any already existing transactions available. basically pass the transaction id around when you need to keep referring to an existing transactions and maintain a 'stack' of active transactions. > Any comment will be helpful to determine or give me an idea how to fix > this bug. > > Thanks for any help. > > -afan > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php