Requests_Cookie::is_expired() WordPress Method

The is_expired() method is used to check whether a given cookie has expired. This is useful for cookies that are set to expire after a certain amount of time.

Requests_Cookie::is_expired() #

Check if a cookie is expired.


Description

Checks the age against $this->reference_time to determine if the cookie is expired.


Top ↑

Return

(boolean) True if expired, false if time is valid.


Top ↑

Source

File: wp-includes/Requests/Cookie.php

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
public function is_expired() {
    // RFC6265, s. 4.1.2.2:
    // If a cookie has both the Max-Age and the Expires attribute, the Max-
    // Age attribute has precedence and controls the expiration date of the
    // cookie.
    if (isset($this->attributes['max-age'])) {
        $max_age = $this->attributes['max-age'];
        return $max_age < $this->reference_time;
    }
 
    if (isset($this->attributes['expires'])) {
        $expires = $this->attributes['expires'];
        return $expires < $this->reference_time;
    }
 
    return false;
}

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.