PluginProbe
Redirection / 4.0
Redirection v4.0
5.10.0 5.9.0 5.8.1 5.8.0 3.7.2 3.7.3 4.0 4.0.1 4.1 4.1.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.3.1 4.3.2 4.3.3 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6.2 4.7.1 All 130 releases
redirection / matches / cookie.php

cookie.php in Redirection 4.0, at matches/cookie.php

33 lines 874 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 include_once dirname( __FILE__ ) . '/http-header.php';
4
5 class Cookie_Match extends Header_Match {
6 function name() {
7 return __( 'URL and cookie', 'redirection' );
8 }
9
10 function get_target( $requested_url, $source_url, Red_Source_Flags $flags ) {
11 $target = false;
12 $matched = Redirection_Request::get_cookie( $this->name ) === $this->value;
13
14 if ( $this->regex ) {
15 $regex = new Red_Regex( $this->value, true );
16 $matched = $regex->is_match( Redirection_Request::get_cookie( $this->name ) );
17 }
18
19 // Check if referrer matches
20 if ( $matched && $this->url_from !== '' ) {
21 $target = $this->url_from;
22 } elseif ( ! $matched && $this->url_notfrom !== '' ) {
23 $target = $this->url_notfrom;
24 }
25
26 if ( $flags->is_regex() && $target ) {
27 $target = $this->get_target_regex_url( $source_url, $target, $requested_url, $flags );
28 }
29
30 return $target;
31 }
32 }
33