Generate authentication cookie contents.

Signature

wp_generate_auth_cookie( $user_id, $expiration, $scheme = 'auth' )
user_id
 (int) User ID
expiration
 (int) Cookie expiration in seconds
scheme
 (string) Optional. The cookie scheme to use: auth, secure_auth, or logged_in
Default: 'auth'

Return

(string) Authentication cookie contents

Source

function wp_generate_auth_cookie($user_id, $expiration, $scheme = 'auth') {
	$user = get_userdata($user_id);

	$pass_frag = substr($user->user_pass, 8, 4);

	$key = wp_hash($user->user_login . $pass_frag . '|' . $expiration, $scheme);
	$hash = hash_hmac('md5', $user->user_login . '|' . $expiration, $key);

	$cookie = $user->user_login . '|' . $expiration . '|' . $hash;

	/**
	 * Filter the authentication cookie.
	 *
	 * @since 2.5.0
	 *
	 * @param string $cookie     Authentication cookie.
	 * @param int    $user_id    User ID.
	 * @param int    $expiration Authentication cookie expiration in seconds.
	 * @param string $scheme     Cookie scheme used. Accepts 'auth', 'secure_auth', or 'logged_in'.
	 */
	return apply_filters( 'auth_cookie', $cookie, $user_id, $expiration, $scheme );
}
WP Trac GitHub

Link here