Search code examples
opencartopencart-3

How to get user_id in Open Cart 3?


I'm developing in admin side. And I needs to find user_id. The code

$this->user->getId()

provides no information. Is there any way to get user id. Thanks.


Solution

  • Here is the best way:

    You cannot directly access user_id from database since it is protected.
    

    So you have to access it from session.

    $this->session->data['user_id'];
    

    This returns the id of currently logged user.