session questions

Reply

Join Date: Jan 2009
Posts: 123
Reputation: shasha821110 is an unknown quantity at this point 
Solved Threads: 2
shasha821110 shasha821110 is offline Offline
Junior Poster

session questions

 
0
  #1
Mar 9th, 2009
Hi, all
i want to have the "add to cart" function in my website which use session function:
Well basically the cart is mostly like others website cart: remember which have already been added and could add something more

Assume i have class.php, A.php and B.php
In my A.php

  1. <?php
  2. require_once("classes.php");
  3. session_start();
  4. $item = new Item($id, (string)$itemXML[0]->name, $quatity, $catalog);//Item is the class i define in class.php
  5. $_SESSION['cart'][$id] = $item;//// Add the item to the $_SESSION['cart'] session variable
  6. ?>

In my B.php
  1. <?php
  2. require_once("classes.php");
  3. session_start();
  4. $cart = $_SESSION['cart'];
  5. foreach($cart as $item)
  6. {
  7.  
  8. //do the array loop
  9. }
  10.  
  11. ?>

So i got the error and warnings information:
Fatal error: Cannot use object of type Item as array
warnings: session-start function: Node no longer exists and Cannot send session cache limiter

Thanks in advance and BOW!!
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 123
Reputation: shasha821110 is an unknown quantity at this point 
Solved Threads: 2
shasha821110 shasha821110 is offline Offline
Junior Poster

Re: session questions

 
0
  #2
Mar 9th, 2009
sorry, changed A.php code:
  1. <?php
  2. require_once("classes.php");
  3. session_start();
  4. $id = $_GET['id'];
  5. $itemXML = $xml->xpath("/root//item[@id='{$id}']");
  6. $item = new Item($id, (string)$itemXML[0]->name, $quatity, $catalog);//Item is the class i define in class.php
  7. $_SESSION['cart'][$id] = $item;//// Add the item to the $_SESSION['cart'] session variable
  8. ?>

Thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC