MarioApprentice Posted February 5, 2013 Share Posted February 5, 2013 (edited) Hey, everybody. I have a problem with session and an object. This is the deal. I'm writing a forum for exercise. Now doing a login/logout script/part of the forum. The script knows that the user is logged in via a session variable that, when set and filled with a certain value, allows a registered user to log in. When someone tries to login, i check in mysql table if his nick and passwords are there. If they are there, i summon another function that gets all of the data about that user and stores it in an object. I then store that object into a session in order to get the users data in another script. After the object has been made all all the user data stored in it and after that object is stored in a session, I then route the program to index.php who then evaluates is the session is set and checks its value. Then it calls antoher function that has to use the object stored in that session. for example... $_SESSION['member_object']->getValue('name') fetches the name of the user. But here comes the problem. I get a fatal error like this... "The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Member" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function..." I presume this says that 'member_object' is not an object, which I checked with is_object() and it really is not an object. I did a require() on the script that has the class that the object was made of, but with no success. I also checked if the object is made in the login.php script and all the information are there which is the main problem. The script then goes to index.php with the header() function, and uses that session where the object is. But there, that object isn't constructed. It's not even an object. I know this is a long question and i probably didn't give enough information to go on, but its a big application and i can't risk of explaining it all so no one will answer. Also, i think it would be rude of me so if anyone knows what this could be, I thank you in andvance. Edited February 5, 2013 by MarioApprentice Quote Link to comment https://forums.phpfreaks.com/topic/274054-incomplete-object/ Share on other sites More sharing options...
trq Posted February 5, 2013 Share Posted February 5, 2013 You need to make sure that the class that this object is instantiated from is defined prior to calling session_start(). Quote Link to comment https://forums.phpfreaks.com/topic/274054-incomplete-object/#findComment-1410198 Share on other sites More sharing options...
MarioApprentice Posted February 5, 2013 Author Share Posted February 5, 2013 wow, that was fast. and simple. thank you. Quote Link to comment https://forums.phpfreaks.com/topic/274054-incomplete-object/#findComment-1410200 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.