Bonesnap wrote:I can understand including it on pages where you're going to actually use the variable, but on all of them?
Yup, all of them. The problem is that even if you don't use the variable, PHP still has to re-create the object when it loads the session data. PHP doesn't have any just-in-time sort of loading of session variables, so it's either all or nothing. In other words, no, there's no way to 'get around this' - you must have defined the class before you call session_start() on any page, otherwise the pages you don't do so will attempt to re-create an object without a class definition and fail (which I believe means the object will be permanently lost when PHP goes to write the session data back to disk, but I could be wrong?).
Either way, one method of mitigating the need to change every single .php script on your site might be to use PHP's auto_prepend_file directive.