class EncryptCookies (View source)

Properties

protected Encrypter $encrypter

The encrypter instance.

protected array<int,string> $except

The names of the cookies that should not be encrypted.

static protected bool $serialize

Indicates if cookies should be serialized.

Methods

void
__construct(Encrypter $encrypter)

Create a new CookieGuard instance.

void
disableFor(string|array $name)

Disable encryption for the given cookie name(s).

Response
handle(Request $request, Closure $next)

Handle an incoming request.

Request
decrypt(Request $request)

Decrypt the cookies on the request.

string|array|null
validateValue(string $key, string $value)

Validate and remove the cookie value prefix from the value.

array
validateArray(string $key, array $value)

Validate and remove the cookie value prefix from all values of an array.

string|array
decryptCookie(string $name, string|array $cookie)

Decrypt the given cookie and return the value.

array
decryptArray(array $cookie)

Decrypt an array based cookie.

Response
encrypt(Response $response)

Encrypt the cookies on an outgoing response.

Cookie
duplicate(Cookie $cookie, mixed $value)

Duplicate a cookie with a new value.

bool
isDisabled(string $name)

Determine whether encryption has been disabled for the given cookie.

static bool
serialized(string $name)

Determine if the cookie contents should be serialized.

Details

void __construct(Encrypter $encrypter)

Create a new CookieGuard instance.

Parameters

Encrypter $encrypter

Return Value

void

void disableFor(string|array $name)

Disable encryption for the given cookie name(s).

Parameters

string|array $name

Return Value

void

Response handle(Request $request, Closure $next)

Handle an incoming request.

Parameters

Request $request
Closure $next

Return Value

Response

protected Request decrypt(Request $request)

Decrypt the cookies on the request.

Parameters

Request $request

Return Value

Request

protected string|array|null validateValue(string $key, string $value)

Validate and remove the cookie value prefix from the value.

Parameters

string $key
string $value

Return Value

string|array|null

protected array validateArray(string $key, array $value)

Validate and remove the cookie value prefix from all values of an array.

Parameters

string $key
array $value

Return Value

array

protected string|array decryptCookie(string $name, string|array $cookie)

Decrypt the given cookie and return the value.

Parameters

string $name
string|array $cookie

Return Value

string|array

protected array decryptArray(array $cookie)

Decrypt an array based cookie.

Parameters

array $cookie

Return Value

array

protected Response encrypt(Response $response)

Encrypt the cookies on an outgoing response.

Parameters

Response $response

Return Value

Response

protected Cookie duplicate(Cookie $cookie, mixed $value)

Duplicate a cookie with a new value.

Parameters

Cookie $cookie
mixed $value

Return Value

Cookie

bool isDisabled(string $name)

Determine whether encryption has been disabled for the given cookie.

Parameters

string $name

Return Value

bool

static bool serialized(string $name)

Determine if the cookie contents should be serialized.

Parameters

string $name

Return Value

bool