<p>If you have the any identifying information about the user (user ID, email, username, UID), you can use one of the UsersService's methods:</p>

<p><a href="https://craftcms.com/classreference/services/UsersService#getUserById-detail" rel="nofollow"><code>craft()-&gt;users-&gt;getUserById()</code></a></p>

<p><a href="https://craftcms.com/classreference/services/UsersService#getUserByUsernameOrEmail-detail" rel="nofollow"><code>craft()-&gt;users-&gt;getUserByUsernameOrEmail()</code></a></p>

<p><a href="https://craftcms.com/classreference/services/UsersService#getUserByUid-detail" rel="nofollow"><code>craft()-&gt;users-&gt;getUserByUid()</code></a></p>

<p><a href="https://craftcms.com/classreference/services/UsersService#getUserByEmail-detail" rel="nofollow"><code>craft()-&gt;users-&gt;getUserByEmail()</code></a></p>

<p>They will each return a <a href="https://craftcms.com/classreference/models/UserModel" rel="nofollow">UserModel</a> object to interact with.</p>

CC BY-SA 3.0
2016-03-18T23:18:36.517Z
2016-03-18T23:18:36.517Z
Brad Bell
<p>Can I directly get the data of the user that I just logged in with <code>craft()-&gt;userSession-&gt;login($username, $password)</code> ? (not from a method that uses the SESSION like <code>craft()-&gt;userSession-&gt;getUser()</code> though)</p>

<php><craft-pro>
Get data of user after login (but not with craft()->userSession->getUser())
# Get data of user after login (but not with craft()->userSession->getUser())

(Asked by: username_0 on 2016-03-18)

Can I directly get the data of the user that I just logged in with `craft()->userSession->login($username, $password)` ? (not from a method that uses the SESSION like `craft()->userSession->getUser()` though)

**Tags:** php, craft-pro

---

## 1 answers

### Answer by username_1 on 2016-03-18. Score: 2 | Accepted answer

If you have the any identifying information about the user (user ID, email, username, UID), you can use one of the UsersService's methods:

[`craft()->users->getUserById()`](https://craftcms.com/classreference/services/UsersService#getUserById-detail)

[`craft()->users->getUserByUsernameOrEmail()`](https://craftcms.com/classreference/services/UsersService#getUserByUsernameOrEmail-detail)

[`craft()->users->getUserByUid()`](https://craftcms.com/classreference/services/UsersService#getUserByUid-detail)

[`craft()->users->getUserByEmail()`](https://craftcms.com/classreference/services/UsersService#getUserByEmail-detail)

They will each return a [UserModel](https://craftcms.com/classreference/models/UserModel) object to interact with.


---

