2

The WordPress function wp_get_current_user() uses the global variable $current_user to get the get current logged-in user info.

What I would like to know is, how does WordPress retrieve the data from session cookie and store it in this global variable ($current_user).

Thank you for you help!!

4
  • WordPress doesn't use session to store current user, it uses Cookies. Commented Dec 23, 2019 at 6:40
  • 1
    The cookie 'wordpress_logged_in_*' is used for this purpose right? If so, then how does wordpress get the current user info from this cookie. Commented Dec 23, 2019 at 6:51
  • The source says all: _wp_get_current_user() and WP_User class Commented Dec 23, 2019 at 8:29
  • 1
    Well it's really wp_validate_logged_in_auth_cookie and wp_validate_auth_cookie, which takes the username and session token (amongst other things) from the cookie and then validates the session token against the user's session_token user meta.
    – Rup
    Commented Dec 24, 2019 at 1:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.