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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.