wp_validate_logged_in_cookie() WordPress Function

The wp_validate_logged_in_cookie() function checks the validity of a user's login cookie. If the cookie is valid, the user is logged in. If the cookie is invalid, the user is not logged in.

wp_validate_logged_in_cookie( int|false $user_id ) #

Validates the logged-in cookie.


Description

Checks the logged-in cookie if the previous auth cookie could not be validated and parsed.

This is a callback for the ‘determine_current_user’ filter, rather than API.


Top ↑

Parameters

$user_id

(int|false)(Required)The user ID (or false) as received from the determine_current_user filter.


Top ↑

Return

(int|false) User ID if validated, false otherwise. If a user ID from an earlier filter callback is received, that value is returned.


Top ↑

Source

File: wp-includes/user.php

function wp_validate_logged_in_cookie( $user_id ) {
	if ( $user_id ) {
		return $user_id;
	}

	if ( is_blog_admin() || is_network_admin() || empty( $_COOKIE[ LOGGED_IN_COOKIE ] ) ) {
		return false;
	}

	return wp_validate_auth_cookie( $_COOKIE[ LOGGED_IN_COOKIE ], 'logged_in' );
}


Top ↑

Changelog

Changelog
VersionDescription
3.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More