Store an object in a PHP session PDF Print E-mail
Written by Bernhard Fischer   
Tuesday, 20 February 2007

The title is a bit different from what the content describes, but that's intended...

You would not want to store an object in a session - you would rather store a reference to an object. This way the object in question is not copied, thus using double memory, for the sake of efficiency.

save the reference:
$_SESSION[”ObjectRef”] = & $RealObject

retrieve it:
$RealObject = & $_SESSION[”ObjectRef”]

Keep in mind that storing objects in session can cause trouble if cookies are used, as a cookie’s size is limited.


Add as favourites (0) | Quote this article on your site | Views: 3231

Be first to comment this article
RSS comments

Write Comment
  • Please keep the topic of messages relevant to the subject of the article.
  • Personal verbal attacks will be deleted.
  • Please don't use comments to plug your web site. Such material will be removed.
  • Just ensure to *Refresh* your browser for a new security code to be displayed prior to clicking on the 'Send' button.
  • Keep in mind that the above process only applies if you simply entered the wrong security code.
Name:
E-mail
Homepage
Title:
Comment:

I wish to be contacted by email regarding additional comments

Powered by AkoComment Tweaked Special Edition v.1.4.6
AkoComment © Copyright 2004 by Arthur Konze - www.mamboportal.com
All right reserved

Last Updated ( Saturday, 03 March 2007 )
 
< Prev