note 60054 added to function.session-write-close
| From: | unspammable-iain at iaindooley dot com | Date: | Sat, 24 Dec 2005 05:57:44 +0000 |
| Subject: | note 60054 added to function.session-write-close | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100650@lists.php.net to get a copy of this message | ||
As we all know, if an object is serialised, then the class definition must be included _before_ it
is unserialised.
My framework has an enormous number of class files, and including them all at the beginning of the
script was really taking it's toll on my system (memory and execution time) so I switched to
including required classes at the top of each class file that used them using require_once.
This caused problems because I start my session at the very beginning of my script's execution,
but all my class files aren't there at the beginning!!
So no in my special 'require' function, I do the following:
if(!class_exists($to_require))
{
session_write_close();
require_once('path/to/classes/'.$to_require.'.php');
session_start();
}
This is a considerably smaller performance hit that including every class that the application uses
at the very beginning of the application.
----
Manual Page -- http://www.php.net/manual/en/function.session-write-close.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60054
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60054&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60054&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60054&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60054&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60054&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60054&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60054&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60054&report=yes
Search -- http://master.php.net/manage/user-notes.php