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

    Join Date
    Aug 2000
    Posts
    1
    Rep Power
    0
    Hello!

    I have a problem with a session and member function of a class.
    I have class named BookUser and one memberfunction named bookUserLoad()

    First I do session_start(), then session_register("user"), then
    $user = new BookUser();

    I have a function:
    function example() {
    global $user;
    $user->bookUserLoad();
    }

    When I do this I get some errors:

    Warning: Unserializing non-existant class: bookuser! No methods will be available!
    (complaining on the session_start line)

    Fatal error: Call to undefined function: bookuserload()
    (complaining on the $user->bookUserLoad() line)

    I can use the member variables but not the member functions. What is wrong?
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <<
    $user = new BookUser();

    I have a function:
    function example() {
    global $user;
    $user->bookUserLoad();
    }
    >>



    First make sure that the class file has been included in your page.

    then try some thing like..

    <?
    $user = new BookUser;
    //Initilize your class..
    $user->bookUserLoad();
    ?>


    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    109
    Rep Power
    15
    It's not possible to use objects/functions with php-sessions!!!
  6. #4
  7. 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
    Actually it is, somewhat, possible.

    Storch,

    Your problem is that you need to define $user first then do your session stuff.

    $user=new BookUser;
    session_start();

    Assuming you used session_register("user") on the preceding page, the properties of $user will now be restored.

    If you try to start_session() before defining the object and you had registered the object on the previous page you'll get the warning you did. BTW, looking at the error message you had named the object $bookuser in the previous page. The object MUST have the same name in each page or it won't work.

Similar Threads

  1. class can't find method
    By tyndyll in forum PHP Development
    Replies: 4
    Last Post: February 17th, 2005, 05:59 AM
  2. session object variable problem... urgent plz
    By hatembr in forum ASP Programming
    Replies: 2
    Last Post: February 11th, 2004, 02:14 AM
  3. instanciating a custom class in global.asa
    By hatembr in forum ASP Programming
    Replies: 2
    Last Post: February 10th, 2004, 03:23 AM

IMN logo majestic logo threadwatch logo seochat tools logo