NYCPHP Meetup

NYPHP.org

[nycphp-talk] Sessions and Classes

csnyder chsnyder at gmail.com
Mon Oct 4 09:06:59 EDT 2004


What Jeff said, and the bottom line is: store the object in $_SESSION.
Just make sure you include the class definition before you call
session_start().

<?php
include_once('lib/myclass.php');
session_start();

if ( empty( $_SESSION['myobj'] ) ) {
  $myobj = new myclass;
  $_SESSION['myobj'] =& $myobj;
}
else {
  $myobj =& $_SESSION['myobj'];
}

// etc..



More information about the talk mailing list