Smutty

MVC Framework

ClassSmutty_Session

The session object will always be passed to your action handlers as the second parameter. It is passed by reference, so for your changes to it to be preserved you need to use the & prefix, like so...

function indexAction( $data, &$session ) {
    // code...
}

You use this object just by setting it's properties, these will automatically be saved for you, and restored on the users next request.

function incrementAction( $data, &$session ) {
    $session->count++;
    echo $session->count;
}

$session->user

You can set any properties you want to the session object, apart from one. The currently logged in user is always assigned to the $user property, and can be accessed like this... function indexAction( $data, &$session ) { if ( $session->user ) // user is logged in! }

Templates

You can access the session object from your templates via the $smutty variable.

The current value of count is {$smutty->session->count}!

Links: Post a comment

Useful Pages

Links