CookieValuePrefix
in package
Helper class to prefix, unprefix, and verify cookie values
Table of Contents
- create() : string
- Create a new cookie value prefix for the given cookie name.
- getVerifiedValue() : string|null
- Verify the provided cookie's value
- remove() : string
- Remove the cookie value prefix.
Methods
create()
Create a new cookie value prefix for the given cookie name.
public
static create(string $name, string $key) : string
Parameters
- $name : string
-
The name of the cookie
- $key : string
-
The encryption key
Return values
string —getVerifiedValue()
Verify the provided cookie's value
public
static getVerifiedValue(string $name, string $value, string $key) : string|null
Parameters
- $name : string
-
The name of the cookie
- $value : string
-
The decrypted value of the cookie to be verified
- $key : string
-
The encryption key used to encrypt the cookie originally
Return values
string|null —$verifiedValue The unprefixed value if it passed verification, otherwise null
remove()
Remove the cookie value prefix.
public
static remove(string $cookieValue) : string
Parameters
- $cookieValue : string