Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to find out my current user id in other page controller after i login?

Tags:

cakephp

i am planing to set a permission on my event index page, which just allow certain user to view which had set when i add the event. After user click into my event, the event controller will 1st check the user id and check the event database which control the user can see which event in his calendar. The permission is added when user create a event and share to other user. Beside, how can i find the current user id to compare with my event database which is the accurate 1?

any suggestion for me to did this function? i need to know the code and concept how i get the current user id to compare with all the event database, and allow the current user see the certain event.

thanks alot for your information.

like image 646
vincent low Avatar asked Nov 10 '09 06:11

vincent low


People also ask

How do I find my current user ID?

The easiest way to get the current logged in user ID with PHP is to use the get_current_user_id() function. This is the ideal solution if you're building custom code and need the current logged in user's ID. Alternatively if you want more than the user ID you can use wp_get_current_user().

How do I find my current user ID in Salesforce?

To get information about the current user, use the @salesforce/user scoped module. import property from '@salesforce/user/ property '; property —The supported properties are Id , which is the user's ID, and isGuest , which is a boolean value indicating whether the user is a guest user.


1 Answers

The recommended approach for getting logged in user data is via the AuthComponent itself:

// in any controller
$userId = $this->Auth->user('id');

See Accessing the logged in user in the Auth section of the CakePHP Book.

like image 133
neilcrookes Avatar answered Oct 03 '22 02:10

neilcrookes