#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    halifax
    Posts
    13
    Rep Power
    0
    hi there..i'm rather new to class/sessions in PHP..im at the humble beginnings of as cart system and seem to have hit a glitch
    if someone could explain what about the following is wrong i would GREATLY appreciate it......
    // *********************************
    session_start();
    session_register("session");

    class cart
    {
    function additem($iid)
    {
    $session["cartitem"] = $iid;
    }

    }

    $bleh = new cart();
    $bleh->additem(21192);

    echo "The itemid is ".$session["cartitem"];
    // *********************************
    this will not retutn $session["cartitem']..
    am i missing something??

    thks in advance..
    cryogen
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Your $session variable is local to the additem() method, therefore it is not the same variable as the $session variable you registered.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    halifax
    Posts
    13
    Rep Power
    0
    ok thks.....

Similar Threads

  1. Codepupil
    By Adachic in forum C Programming
    Replies: 3
    Last Post: February 6th, 2004, 06:50 PM
  2. Learning Mouse Event Handling.
    By coredumped in forum Java Help
    Replies: 5
    Last Post: December 4th, 2003, 08:44 AM
  3. class 1 functions used in class 2
    By ioScream in forum PHP Development
    Replies: 4
    Last Post: October 30th, 2003, 03:15 PM
  4. virtual base class inheritance question
    By Rooster in forum C Programming
    Replies: 3
    Last Post: October 18th, 2003, 09:08 AM
  5. compiling .java, thought I knew what I was doing?!
    By geoffgarcia in forum Java Help
    Replies: 10
    Last Post: September 9th, 2003, 10:56 AM

IMN logo majestic logo threadwatch logo seochat tools logo