Created
March 10, 2014 20:11
-
-
Save tmazur/9473276 to your computer and use it in GitHub Desktop.
CakePHP: get session user_id from inside model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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