WordPress at Your Fingertips
function is not described

WC_Session_Handler::get_session_cookie() public WC 1.0

Get the session cookie, if set. Otherwise return false.

Session cookies without a customer ID are invalid.

{} It's a method of the class: WC_Session_Handler{}

No Hooks.

Return

true|false|Array.

Usage

$WC_Session_Handler = new WC_Session_Handler();
$WC_Session_Handler->get_session_cookie();

Code of WC_Session_Handler::get_session_cookie() WC 5.9.0

public function get_session_cookie() {
	$cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.

	if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
		return false;
	}

	list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );

	if ( empty( $customer_id ) ) {
		return false;
	}

	// Validate hash.
	$to_hash = $customer_id . '|' . $session_expiration;
	$hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );

	if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
		return false;
	}

	return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
}