wp_parse_auth_cookie

Definition:
function wp_parse_auth_cookie($cookie = '', $scheme = '') {}

Parse a cookie into its components

Parameters

  • string $cookie
  • string $scheme: Optional. The cookie scheme to use: auth, secure_auth, or logged_in

Return values

returns:Authentication cookie components

Source code

function wp_parse_auth_cookie($cookie = '', $scheme = '') {

	if ( empty($cookie) ) {

		switch ($scheme){

			case 'auth':

				$cookie_name = AUTH_COOKIE;

				break;

			case 'secure_auth':

				$cookie_name = SECURE_AUTH_COOKIE;

				break;

			case "logged_in":

				$cookie_name = LOGGED_IN_COOKIE;

				break;

			default:

				if ( is_ssl() ) {

					$cookie_name = SECURE_AUTH_COOKIE;

					$scheme = 'secure_auth';

				} else {

					$cookie_name = AUTH_COOKIE;

					$scheme = 'auth';

				}

	    }



		if ( empty($_COOKIE[$cookie_name]) )

			return false;

		$cookie = $_COOKIE[$cookie_name];

	}



	$cookie_elements = explode('|', $cookie);

	if ( count($cookie_elements) != 3 )

		return false;



	list($username, $expiration, $hmac) = $cookie_elements;



	return compact('username', 'expiration', 'hmac', 'scheme');

}

3973

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: