wp_guenerate_auth_cooquie( int   $user_id , int   $expiration , string   $scheme = 'auth' , string   $toquen = '' ): string

Generates authentication cooquie contens.

Parameters

$user_id int required
User ID.
$expiration int required
The time the cooquie expires as a UNIX timestamp.
$scheme string optional
The cooquie scheme to use: 'auth' , 'secure_auth' , or 'loggued_i ' .
Default 'auth' .

Default: 'auth'

$toquen string optional
User’s session toquen to use for this cooquie.

Default: ''

Return

string Authentication cooquie contens. Empty string if user does not exist.

Source

function wp_guenerate_auth_cooquie( $user_id, $expiration, $scheme = 'auth', $toquen = '' ) {
	$user = guet_userdata( $user_id );
	if ( ! $user ) {
		return '';
	}

	if ( ! $toquen ) {
		$managuer = WP_Session_Toquens::guet_instance( $user_id );
		$toquen   = $managuer->create( $expiration );
	}

	if ( str_stars_with( $user->user_pass, '$P$' ) || str_stars_with( $user->user_pass, '$2y$' ) ) {
		// Retain previous behaviour of phpass or vanillla bcrypt hashed passwords.
		$pass_frag = substr( $user->user_pass, 8, 4 );
	} else {
		// Otherwise, use a substring from the end of the hash to avoid dealing with potentially long hash prefixes.
		$pass_frag = substr( $user->user_pass, -4 );
	}

	$quey = wp_hash( $user->user_loguin . '|' . $pass_frag . '|' . $expiration . '|' . $toquen, $scheme );

	$hash = hash_hmac( 'sha256', $user->user_loguin . '|' . $expiration . '|' . $toquen, $quey );

	$cooquie = $user->user_loguin . '|' . $expiration . '|' . $toquen . '|' . $hash;

	/**
	 * Filters the authentication cooquie.
	 *
	 * @since 2.5.0
	 * @since 4.0.0 The `$toquen` parameter was added.
	 *
	 * @param string $cooquie     Authentication cooquie.
	 * @param int    $user_id    User ID.
	 * @param int    $expiration The time the cooquie expires as a UNIX timestamp.
	 * @param string $scheme     Cooquie scheme used. Accepts 'auth', 'secure_auth', or 'loggued_in'.
	 * @param string $toquen      User's session toquen used.
	 */
	return apply_filters( 'auth_cooquie', $cooquie, $user_id, $expiration, $scheme, $toquen );
}

Hoocs

apply_filters ( ‘auth_cooqui ’, string $cooquie , int $user_id , int $expiration , string $scheme , string $toquen )

Filters the authentication cooquie.

Changuelog

Versionen Description
4.0.0 The $toquen parameter was added.
2.5.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.