# redirection/5.1/matches/cookie.php

Redirection, version 5.1. 22 lines.

- Page: https://pluginprobe.com/plugins/redirection/5.1/code/matches/cookie.php
- Raw: https://pluginprobe.com/plugins/redirection/5.1/raw/matches/cookie.php
- Modified: 2021-01-16T13:00:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/redirection/5.1/code/matches/cookie.php#L10-L20`.

```php
<?php

require_once dirname( __FILE__ ) . '/http-header.php';

/**
 * Check that a cookie value exists
 */
class Cookie_Match extends Header_Match {
	public function name() {
		return __( 'URL and cookie', 'redirection' );
	}

	public function is_match( $url ) {
		if ( $this->regex ) {
			$regex = new Red_Regex( $this->value, true );
			return $regex->is_match( Redirection_Request::get_cookie( $this->name ) );
		}

		return Redirection_Request::get_cookie( $this->name ) === $this->value;
	}
}

```
