PHP Classes

Troubleshooting!

Recommend this page to a friend!

      Object Session Saver  >  All threads  >  Troubleshooting!  >  (Un) Subscribe thread alerts  
Subject:Troubleshooting!
Summary:Help! Can't manage to Object Session Saver to work.
Messages:2
Author:Simon
Date:2007-04-04 13:31:25
Update:2007-04-04 13:52:50
 

  1. Troubleshooting!   Reply   Report abuse  
Picture of Simon Simon - 2007-04-04 13:31:25
I'm trying to pass an object using the Object Session Saver class and I can't retrieve the information on a new page. I'm not too sure but I don't think this Session Saver is working correctly.

--first page

$objectsForSaving = array("HeadAdmin");
SessionSaver::addObjects($objectsForSaving);

SessionSaver::restoreObjects();

$head = new HeadAdmin(1, "goCampus");
HeadAdmin::$_firstName = "Joshua";

SessionSaver::saveObjects();

--second page - POSTED from the first page

$objectsForSaving = array("HeadAdmin");
SessionSaver::addObjects($objectsForSaving);

$head = new HeadAdmin(1, "goCampus");
$head = SessionSaver::restoreObjects();

echo "Your Name Is: ". $head->_firstName;

--the output
Your Name Is:

  2. Re: Troubleshooting!   Reply   Report abuse  
Picture of Vit Ek Vit Ek - 2007-04-04 13:52:50 - In reply to message 1 from Simon
If this is all you have in those files, than you must add a session initialization routine, something like:
if (empty($_SESSION)) {
session_start();
}