CakePHP: Accessing session data from within a controller

tutur49

New Member
I have an edit action in the users controller. What I want to do is redirect anyone to a different action if their Auth.User.id does not equal the id of the user they are trying to edit. I can access variables in my views like this:\[code\]if($session->read('Auth.User.id') != $id){\[/code\]but this doesn't work in my controller. Getting:\[code\]Undefined variable: session\[/code\]How do I access session data within a controller? also, if any has a better way of achieving what I want to do, feel free to add!Thanks,Jonesy
 
Back
Top