Skip to content

Instantly share code, notes, and snippets.

@tmazur
Created March 10, 2014 20:11
Show Gist options
  • Save tmazur/9473276 to your computer and use it in GitHub Desktop.
Save tmazur/9473276 to your computer and use it in GitHub Desktop.
CakePHP: get session user_id from inside model
/**
* get user_id from session
* @return int current user_id
*/
public function getUserId() {
App::uses('CakeSession', 'Model/Datasource');
return CakeSession::read('Auth.User.id');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment