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

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

PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea -

asp.net - call stack missing info on mono with apache and mod_mono -