Cookie.php
1 week ago
Noop.php
1 week ago
Store.php
1 week ago
Strategy.php
1 week ago
WcSession.php
1 week ago
Cookie.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WCML\User\Store; |
| 4 | |
| 5 | |
| 6 | class Cookie implements Strategy { |
| 7 | |
| 8 | public $cookieHandler; |
| 9 | |
| 10 | |
| 11 | public function __construct( \WPML_Cookie $cookieHandler ) { |
| 12 | $this->cookieHandler = $cookieHandler; |
| 13 | } |
| 14 | |
| 15 | public function get( $key ) { |
| 16 | |
| 17 | return $this->cookieHandler->get_cookie( $key ); |
| 18 | } |
| 19 | |
| 20 | public function set( $key, $value ) { |
| 21 | |
| 22 | if ( ! $this->cookieHandler->headers_sent() ) { |
| 23 | |
| 24 | $expiration = time() + (int) apply_filters( 'wcml_cookie_expiration', 48 * HOUR_IN_SECONDS, $key ); |
| 25 | |
| 26 | $this->cookieHandler->set_cookie( $key, $value, $expiration, COOKIEPATH, COOKIE_DOMAIN ); |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 |