I'm trying to use CakePHP's session helper, like this inside a controller:
$this->Session->write('cart', $cart);
But it does not work. I get this error:
Fatal error: Call to a member function write() on a non-object in ...
It's enabled in the config file, I added the session helper to the controller and the app controller
Turns out, you also need to add Session as a component, so AppController looks like this:
class AppController extends Controller {
public $layout = 'website';
public $components = array(
'Paginator',
'DebugKit.Toolbar',
'Session'
);
public $helpers = array(
'Html',
'Js' => array('Jquery'),
'Session'
);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With