WP_Recovery_Mode_Cookie_Service::set_cookie() WordPress Method

The WP_Recovery_Mode_Cookie_Service::set_cookie() method is used to set a cookie for use in WordPress recovery mode. This mode is used when a website is experiencing technical difficulties and needs to be taken offline for maintenance. When a user visits a WordPress site in recovery mode, they will be prompted to enter their username and password. Once they have done so, they will be able to access the site's admin area and make changes as needed.

WP_Recovery_Mode_Cookie_Service::set_cookie() #

Sets the recovery mode cookie.


Description

This must be immediately followed by exiting the request.


Top ↑

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;

		setcookie( RECOVERY_MODE_COOKIE, $value, $expire, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true );

		if ( COOKIEPATH !== SITECOOKIEPATH ) {
			setcookie( RECOVERY_MODE_COOKIE, $value, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, is_ssl(), true );
		}
	}


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.