LLMS_Session::get_cookie()

Retrieve an validate the session cookie


Return Return

(false|mixed[])


Top ↑

Source Source

File: includes/class.llms.session.php

121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
protected function get_cookie() {
 
    $value = isset( $_COOKIE[ $this->cookie ] ) ? sanitize_text_field( wp_unslash( $_COOKIE[ $this->cookie ] ) ) : false;
 
    if ( empty( $value ) || ! is_string( $value ) ) {
        return false;
    }
 
    /**
     * Explode the cookie into it's parts.
     *
     * @param string|int $0 User ID.
     * @param int        $1 Expiration timestamp.
     * @param int        $2 Expiration variance timestamp.
     * @param string     $3 Cookie hash.
     */
    $parts = explode( '||', $value );
 
    if ( empty( $parts[0] ) || empty( $parts[3] ) ) {
        return false;
    }
 
    $hash_str = sprintf( '%1$s|%2$s', $parts[0], $parts[1] );
    $expected = hash_hmac( 'md5', $hash_str, wp_hash( $hash_str ) );
 
    if ( ! hash_equals( $expected, $parts[3] ) ) {
        return false;
    }
 
    return $parts;
 
}


Top ↑

Changelog Changelog

Changelog
Version Description
4.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.