(Man, this reply-all takes some getting used to...)

As long as your objects don't contain any reference variables (see
manual) you can just assign the object to an element of $_SESSION and
leave it at that.  The session management code takes care of the
serialization.  So you're just duplicating work thats already done by
serializing the object before putting it in $_SESSION.

$_SESSION['myobj'] = new MyObj('string data',63453.2342);

Then you can access it from any script during the session...


You can also write custom session storage code and set it using
session_set_save_handler().  The default save handler writes to flat
files.  You could write a handler that saves your data to a database
(or whatever storage mechanism you wish to use) which with proper
database design and caching will greatly improve the performance of
handling the amount of session data you are talking about.

On Tue, Jun 16, 2009 at 11:56 PM, James Colannino<ja...@colannino.org> wrote:
> Martin Scotta wrote:
>> You can use $_SESSION to store the object, and serialize to convert to
>> string and reverse
> I like that idea.  I think I may end up going that route.
> I have one question.  This is VERY hypothetical, and mostly just to
> satisfy a curiosity, but let's assume that you write an application that
> supports a few hundred users, each of which happen to be logged on at
> the same time.
> Assuming that serialization/unserialization happens frequently in the
> application, how severely will that impact performance?  I'd imagine
> quite a bit, since you're reading/writing a lot from disk, which is
> inherently slow.
> I suppose one interesting way to alleviate this problem on a per-machine
> basis would be to implement /tmp in a RAM disk, so that session data is
> effectively written to and read from memory instead of to and from the disk.
> I suppose the best solution would be to design things such that as
> little data as possible is serialized between page refreshes.
> James
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

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

Reply via email to