Preload custom cookie

In some cases, you might want to preload the cache for one value of a dynamic cookie instead of the regular cache version

To achieve it, you can customize the following code snippet. Replace any instances of  cookie_name and cookie_value with the name and the value of the cookie you would like to preload.

function custom_cookie_preload( $args ) {
	$cookie = new WP_Http_Cookie( 'cookie_name' );
	$cookie->name = 'cookie_name';
	$cookie->value = 'cookie_value';
	$cookies[] = $cookie;
	
	$args['cookies'] = $cookies;
	
	return $args;
}
add_filter( 'rocket_preload_url_request_args', 'custom_cookie_preload', PHP_INT_MAX ); 

You need to add the customized code to the functions.php of your child theme or use a code snippets plugin.
Reference: How to add code snippets.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.