Jump to content

Incomplete Object stored in Session


berridgeab

Recommended Posts

Hello

 

I am struggling to store a simple PHP class within a PHP session. When I try to access the class stored in my session I get the following

 

"Fatal error: main(): The script tried to execute a method or access a property of an incomplete object."

 

Google tells me this is because I haven't included my class definition before calling session_start(). The solution would be to require_once() every PHP class my site uses before calling session_start().

 

Only thing is there are about 100 classes. Would this not add a ton of overhead to every PHP page that loads (Because it is loading 90+ unneeded classes) or is this common practice?

 

Currently I only require_once() the classes I need on a per page basis so I reduce overhead. But most of these require_once() calls come after I have called session_start().

Link to comment
https://forums.phpfreaks.com/topic/246463-incomplete-object-stored-in-session/
Share on other sites

Yes I can do, but that could be any one of 25 - 50 classes and my session_start() happens quite early on.

 

The only solution I can see is to have some way of loading my required classes before the session_start() is called but thats quite a big project rewrite.

 

Thanks anyway.  ;D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.