code: protected function _userId() {
          if ( array_key_exists('userId', $this->_context) ) {
              $userId = ($this->_context['userId']) ? (int) $this->_context['userId'] : null;
              unset($this->_context['userId']);
              return $userId;
          }
  
          if ( isset($_SESSION) && is_array($_SESSION) )
              return Hash::get($_SESSION, $this->config('userId'));
  
          return null;
      }
docs: Get user_id
  @return int