How can I have an object class store into PHP session and then get it in my next page as variable. Could you help?
Here is my class.inc.php
class sho
Extending on Jakes answer It can be done with very little hassle like everything in php. Here is a test case:
session_start();
$_SESSION['object'] = empty($_SESSION['object'])? (object)array('count' => 0) : $_SESSION['object'];
echo $_SESSION['object']->count++;
It will output count increased by 1 on every page load. However you will have to be careful when you first initiate the $_SESSION variable to check whether it is already set. You dont want to over write the value everytime. So be sure to do:
if (empty($_SESSION['SomeShop']))
$_SESSION['SomeShop'] = new Shop();
or better yet:
if (!$_SESSION['SomeShop'] instanceof Shop)
$_SESSION['SomeShop'] = new Shop();