TomTees Posted September 30, 2010 Share Posted September 30, 2010 I was told that using a Session will allow me to capture an Object and pass it between pages. I tried following what I read online and what someone sugegsted but it is not working. This is the error I get when running my test application... Catchable fatal error: Argument 1 passed to Microwave::receiveItem() must be an instance of Bowl, instance of __PHP_Incomplete_Class given, called in /Users/user1/Documents/DEV/++htdocs/Soup/cook.php on line 13 and defined in /Users/user1/Documents/DEV/++htdocs/Soup/classes/Soup.class.php on line 31 Call Stack # Time Memory Function Location 1 0.0095 56412 {main}( ) ../cook.php:0 2 0.0101 68272 Microwave->receiveItem( ) ../cook.php:13 I would really appreciate it if someone could look at my code and see where the problem is at. My guess is that it is in cook.php, but who knows?! Attached is a ZIP of my entire directory structure. Thanks, TomTees [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/214856-issue-using-session-with-objects/ Share on other sites More sharing options...
AbraCadaver Posted September 30, 2010 Share Posted September 30, 2010 I'm not looking at the zip but you must serialize the object before you put it in the session and then you must include the class on the next page before you start the session or try to unserialize it, can't remember which. Quote Link to comment https://forums.phpfreaks.com/topic/214856-issue-using-session-with-objects/#findComment-1117721 Share on other sites More sharing options...
ignace Posted October 1, 2010 Share Posted October 1, 2010 you must include the class on the next page before you start the session That one. You also should add a __sleep() method to serialize your class data. Quote Link to comment https://forums.phpfreaks.com/topic/214856-issue-using-session-with-objects/#findComment-1117843 Share on other sites More sharing options...
PFMaBiSmAd Posted October 1, 2010 Share Posted October 1, 2010 Php serializes/un-serializes all session data when it is written/read to/from the session data file. You don't need to do it a second time in your class. Quote Link to comment https://forums.phpfreaks.com/topic/214856-issue-using-session-with-objects/#findComment-1117901 Share on other sites More sharing options...
TomTees Posted October 1, 2010 Author Share Posted October 1, 2010 Php serializes/un-serializes all session data when it is written/read to/from the session data file. You don't need to do it a second time in your class. I thought that is what I read in the PHP manual, but as usual, the PHP manual isn't the most well written document in the world!!! It implies that PHP will be changing how all of this is handled... So, to be certain, PFMaBiSmAd, you are saying that if I store my Objects in a Session variable, then that is all I have to do, correct? (And I can ignore all of this repeated talk about Serialization, right?) On a related note, how do the "pros" do all of this stuff?? For instance, let's say I'm back to working on my *real* website, and I an working with things like "User" and "Registration" and "Shopping Cart" classes that have important and sensitive data n them. What is the safest way to handle things as a User naviagtes my E-commerce site?? From what I was reading over at Stack Overflow, PHP is considered "wimpy" in how it does not handle state between web pages the way a more sophisticated solution like Java does?! Can someone please elaborate on this topic?? (I am very interested and concerned, because I want to build a RELIABLE and SECURE E-commerce site, and don't want to be taking any shortcuts!) Thanks, TomTees Quote Link to comment https://forums.phpfreaks.com/topic/214856-issue-using-session-with-objects/#findComment-1117986 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.