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

silverlight - Applying a style to ItemContainerStyle in C# -

c# - NullReferenceException in MySqlClient.NativeDriver -

php - Updating recent updates - Problem in procedure - Any other approach? -