WP_Recovery_Mode_Cookie_Service::set_cookie()

Sets the recovery mode cookie.


Description

This must be immediately followed by exiting the request.


Source

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

	public function set_cookie() {

		$value = $this->generate_cookie();

		/**
		 * Filters the length of time a Recovery Mode cookie is valid for.
		 *
		 * @since 5.2.0
		 *
		 * @param int $length Length in seconds.
		 */
		$length = apply_filters( 'recovery_mode_cookie_length', WEEK_IN_SECONDS );

		$expire = time() + $length;

		$cookie_options = array(
			'expires' => $expire,
			'path' => COOKIEPATH,
			'domain' => COOKIE_DOMAIN,
			'secure' => is_ssl(),
			'httponly' => true,
			'samesite' => 'Strict',
		);

		setcookie( RECOVERY_MODE_COOKIE, $value, $cookie_options );

		if ( COOKIEPATH !== SITECOOKIEPATH ) {
			$cookie_options['path'] = SITECOOKIEPATH;
			setcookie( RECOVERY_MODE_COOKIE, $value, $cookie_options );
		}
	}

Changelog

Changelog
Version Description
5.2.0 Introduced.