WP_Recovery_Mode_Cookie_Service::get_session_id_from_cookie() WordPress Method

The WP_Recovery_Mode_Cookie_Service::get_session_id_from_cookie() method is used to get the session ID from a cookie. This is used to help with recovery mode when a user's session has expired.

WP_Recovery_Mode_Cookie_Service::get_session_id_from_cookie( string $cookie = '' ) #

Gets the session identifier from the cookie.


Description

The cookie should be validated before calling this API.


Top ↑

Parameters

$cookie

(string)(Optional)y specify the cookie string. If omitted, it will be retrieved from the super global.

Default value: ''


Top ↑

Return

(string|WP_Error) Session ID on success, or error object on failure.


Top ↑

Source

File: wp-includes/class-wp-recovery-mode-cookie-service.php

	public function get_session_id_from_cookie( $cookie = '' ) {
		if ( ! $cookie ) {
			if ( empty( $_COOKIE[ RECOVERY_MODE_COOKIE ] ) ) {
				return new WP_Error( 'no_cookie', __( 'No cookie present.' ) );
			}

			$cookie = $_COOKIE[ RECOVERY_MODE_COOKIE ];
		}

		$parts = $this->parse_cookie( $cookie );
		if ( is_wp_error( $parts ) ) {
			return $parts;
		}

		list( , , $random ) = $parts;

		return sha1( $random );
	}


Top ↑

Changelog

Changelog
VersionDescription
5.2.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.