i have an object that i want to save into the session.
my app is one page, using $_GET and $
after scouring the net, i have come up with the following solution, placed at the top of my page:
[code=php]
include(“MyClass.php”);
session_start();
if(!isset($_SESSION[‘object’]))
{
//first time loaded, create new object and store in session
$MyObject = new MyClass;
$_SESSION[‘object’] = $MyObject;
}else{
//object already loaded
$MyObject = $_SESSION[‘object’];
}
this will then work using the following notation:
[code=php]
$_SESSION[‘object’]->objProperty
or
[code=php]
$_SESSION[‘object’]->objMethod()
but i was wondering why i can’t use $MyObject->objProperty, which i specfiy in the else clause of the loop?
?