php - CakePHP: Accessing session data from within a controller -


i have edit action in users controller. want redirect different action if auth.user.id not equal id of user trying edit.

i can access variables in views this:

if($session->read('auth.user.id') != $id){ 

but doesn't work in controller. getting:

undefined variable: session 

how access session data within controller? also, if has better way of achieving want do, feel free add!

thanks,

jonesy

you must first add session component in controller:

var $components= array('session');

you can access in methods via $this->session


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -