title: Adjust Array Value in Shopping Cart based on User login state
body: <p>How would I adjust individual values within the <code>$_SESSION array</code> depending on whether the user is logged_in or not logged_in. So basically the array values equate to the individual item prices within the shopping cart and will be adjusted if the user logs in or logs out of the <code>SESSION</code>. </p>
  
  <p>Here's my current code:</p>
  
  <p><strong>PHP</strong></p>
  
  <pre><code> if(!empty($_SESSION)){
  
      foreach($_SESSION['basket'] as $b){
  
      if ($session-&gt;logged_in) { $b['itemprice'] = ""; }
  
              $sub_total = $b['itemprice'] * $b['itemqty'];
              $total = $total + $sub_total;
  
            // display contents of shopping cart
  
           } 
              } 
      elseif (empty($_SESSION)) { ?&gt;
  
      // display message informing the user that their cart is empty
  </code></pre>
  
  <p><strong>MYSQL</strong></p>
  
  <pre><code>              $itemids = array();
                foreach ($_SESSION['basket'] as $item) {
                $itemids[] = "'" . $item['itemid'] . "'";
                }
  
                $itemids_str = implode(',', $itemids);
  
                $query = mysql_query("SELECT product_id, price, price_100 FROM product    WHERE product_id IN ($itemids_str)");
                while ($result=mysql_fetch_array($query)) { }
  </code></pre>
  
  <p>The closest I've come to getting this to work is each product in the cart is given the same price which changes if the user logs in or out. However, I need each item to change to the new price specific to that items product ID. </p>
  
  <p>Some of our members receive a discount on certain items, so once the user logs in from being a <code>GUEST</code> to the registered <code>USER</code> the price needs to be changed on page refresh. </p>
  
  <p>An example being :</p>
  
  <pre><code>**Logged in == FALSE**
  
  Item 1      Price: 100.00 
  Item 2      Price: 100.00
  
  **User logs in (Logged in == TRUE)**
  
  Item 1      Price:  85.00
  Item 2      Price:  94.00
  </code></pre>
  
  <p>I hope I've been clear - any advice would be appreciated. 
  Thanks</p>