Re: losing MySQL resource

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Stan wrote:
I don't understand the process.  When session_start() reconnects to a (the)
session, objects saved as $_SESSION variables must be "recreated".  To do
this requires the class definition.  So the class definition must be loaded
prior to calling session_start().



Some other languages I've written in had a process called serialization
through which objects were saved.  And an opposite (deserialization?)
process through which objects were restored.  To have "persistent" objects
requires some way to "save" the objects for the next invocation of the
application (PHP in this case).  Deserialization necessarily requires the
template upon which the original object was built (the class definition).



I found http://us.php.net/serialize in the online PHP manual.  I also found
http://us.php.net/manual/en/language.oop5.autoload.php in the online PHP
manual (I have not tried autoload).



I simply moved the require_once("class_definitions.inc"); to appear
immediately before my session_start(); and everything worked thereafter.

When data gets serialized in the session, it only stores the data itself (public/private variables). It does not store the actual class (your methods) and the code that makes it all work. That would just bloat the session and cause other extra headaches.

So before the data can be properly loaded, you need the class.

http://us.php.net/manual/en/language.oop5.serialization.php

explains things a little better I hope.

--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux