WP_Recovery_Mode_Cookie_Service::parse_cookie()privateWP 5.2.0

Parses the cookie into its four parts.

Method of the class: WP_Recovery_Mode_Cookie_Service{}

No Hooks.

Return

Array|WP_Error. Cookie parts array, or error object on failure.

Usage

// private - for code of main (parent) class only
$result = $this->parse_cookie( $cookie );
$cookie(string) (required)
Cookie content.

Changelog

Since 5.2.0 Introduced.

WP_Recovery_Mode_Cookie_Service::parse_cookie() code WP 6.5.2

private function parse_cookie( $cookie ) {
	$cookie = base64_decode( $cookie );
	$parts  = explode( '|', $cookie );

	if ( 4 !== count( $parts ) ) {
		return new WP_Error( 'invalid_format', __( 'Invalid cookie format.' ) );
	}

	return $parts;
}