CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.10 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.10
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • Http
      • Client
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

Interface CookieInterface

Cookie Interface

Namespace: Cake\Http\Cookie

Constants

  • string
    EXPIRES_FORMAT ¶
    'D, d-M-Y H:i:s T'

    Expires attribute format.

  • string
    SAMESITE_LAX ¶
    'Lax'

    SameSite attribute value: Lax

  • string
    SAMESITE_NONE ¶
    'None'

    SameSite attribute value: None

  • string
    SAMESITE_STRICT ¶
    'Strict'

    SameSite attribute value: Strict

  • string[]
    SAMESITE_VALUES ¶
    [self::SAMESITE_LAX, self::SAMESITE_STRICT, self::SAMESITE_NONE]

    Valid values for "SameSite" attribute.

Method Summary

  • getDomain() public

    Get the domain attribute.

  • getExpiresTimestamp() public

    Get the timestamp from the expiration time

  • getExpiry() public

    Get the current expiry time

  • getFormattedExpires() public

    Builds the expiration value part of the header string

  • getId() public

    Get the id for a cookie

  • getName() public

    Gets the cookie name

  • getPath() public

    Get the path attribute.

  • getSameSite() public @method
  • getStringValue() public

    Gets the cookie value as a string.

  • getValue() public

    Gets the cookie value

  • isExpired() public

    Check if a cookie is expired when compared to $time

  • isHttpOnly() public

    Check if the cookie is HTTP only

  • isSecure() public

    Check if the cookie is secure

  • toHeaderValue() public

    Returns the cookie as header value

  • withDomain() public

    Create a cookie with an updated domain

  • withExpired() public

    Create a new cookie that will expire/delete the cookie from the browser.

  • withExpiry() public

    Create a cookie with an updated expiration date

  • withHttpOnly() public

    Create a cookie with HTTP Only updated

  • withName() public

    Sets the cookie name

  • withNeverExpire() public

    Create a new cookie that will virtually never expire.

  • withPath() public

    Create a new cookie with an updated path

  • withSameSite() public @method
  • withSecure() public

    Create a cookie with Secure updated

  • withValue() public

    Create a cookie with an updated value.

Method Detail

getDomain() ¶ public

getDomain(): string

Get the domain attribute.

Returns
string

getExpiresTimestamp() ¶ public

getExpiresTimestamp(): string|null

Get the timestamp from the expiration time

Timestamps are strings as large timestamps can overflow MAX_INT in 32bit systems.

Returns
string|null

getExpiry() ¶ public

getExpiry(): DateTime|DateTimeImmutable|null

Get the current expiry time

Returns
DateTime|DateTimeImmutable|null

getFormattedExpires() ¶ public

getFormattedExpires(): string

Builds the expiration value part of the header string

Returns
string

getId() ¶ public

getId(): string

Get the id for a cookie

Cookies are unique across name, domain, path tuples.

Returns
string

getName() ¶ public

getName(): string

Gets the cookie name

Returns
string

getPath() ¶ public

getPath(): string

Get the path attribute.

Returns
string

getSameSite() ¶ public @method

getSameSite(): string|null
Returns
string|null

getStringValue() ¶ public

getStringValue(): string

Gets the cookie value as a string.

This will collapse any complex data in the cookie with json_encode()

Returns
string

getValue() ¶ public

getValue(): string|array

Gets the cookie value

Returns
string|array

isExpired() ¶ public

isExpired(DateTime|DateTimeImmutable $time = null): bool

Check if a cookie is expired when compared to $time

Cookies without an expiration date always return false.

Parameters
DateTime|DateTimeImmutable $time optional

The time to test against. Defaults to 'now' in UTC.

Returns
bool

isHttpOnly() ¶ public

isHttpOnly(): bool

Check if the cookie is HTTP only

Returns
bool

isSecure() ¶ public

isSecure(): bool

Check if the cookie is secure

Returns
bool

toHeaderValue() ¶ public

toHeaderValue(): string

Returns the cookie as header value

Returns
string

withDomain() ¶ public

withDomain(string $domain): static

Create a cookie with an updated domain

Parameters
string $domain

Domain to set

Returns
static

withExpired() ¶ public

withExpired(): static

Create a new cookie that will expire/delete the cookie from the browser.

This is done by setting the expiration time to 1 year ago

Returns
static

withExpiry() ¶ public

withExpiry(DateTime|DateTimeImmutable $dateTime): static

Create a cookie with an updated expiration date

Parameters
DateTime|DateTimeImmutable $dateTime

Date time object

Returns
static

withHttpOnly() ¶ public

withHttpOnly(bool $httpOnly): static

Create a cookie with HTTP Only updated

Parameters
bool $httpOnly

HTTP Only

Returns
static

withName() ¶ public

withName(string $name): static

Sets the cookie name

Parameters
string $name

Name of the cookie

Returns
static

withNeverExpire() ¶ public

withNeverExpire(): static

Create a new cookie that will virtually never expire.

Returns
static

withPath() ¶ public

withPath(string $path): static

Create a new cookie with an updated path

Parameters
string $path

Sets the path

Returns
static

withSameSite() ¶ public @method

withSameSite(mixed $sameSite = null): static
Parameters
$sameSite optional
Returns
static

withSecure() ¶ public

withSecure(bool $secure): static

Create a cookie with Secure updated

Parameters
bool $secure

Secure attribute value

Returns
static

withValue() ¶ public

withValue(string|array $value): static

Create a cookie with an updated value.

Parameters
string|array $value

Value of the cookie to set

Returns
static
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs