CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 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

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • Cookie
  • CookieCollection

Interfaces

  • CookieInterface

Interface CookieInterface

Cookie Interface

Direct Implementers
  • Cake\Http\Cookie\Cookie
Namespace: Cake\Http\Cookie
Location: Http/Cookie/CookieInterface.php

Constants summary

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

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.
  • 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
  • withSecure() public
    Create a cookie with Secure updated
  • withValue() public
    Create a cookie with an updated value.

Method Detail

getDomain() public ¶

getDomain( )

Get the domain attribute.

Returns
string

getExpiresTimestamp() public ¶

getExpiresTimestamp( )

Get the timestamp from the expiration time

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

Returns
string|null
The expiry time as a string timestamp.

getExpiry() public ¶

getExpiry( )

Get the current expiry time

Returns
DateTime|DateTimeImmutable|null
Timestamp of expiry or null

getFormattedExpires() public ¶

getFormattedExpires( )

Builds the expiration value part of the header string

Returns
string

getId() public ¶

getId( )

Get the id for a cookie

Cookies are unique across name, domain, path tuples.

Returns
string

getName() public ¶

getName( )

Gets the cookie name

Returns
string

getPath() public ¶

getPath( )

Get the path attribute.

Returns
string

getStringValue() public ¶

getStringValue( )

Gets the cookie value as a string.

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

Returns
string

getValue() public ¶

getValue( )

Gets the cookie value

Returns
string|array

isExpired() public ¶

isExpired( DateTime|DateTimeImmutable $time = null )

Check if a cookie is expired when compared to $time

Cookies without an expiration date always return false.

Parameters
DateTime|DateTimeImmutable $time optional null
The time to test against. Defaults to 'now' in UTC.
Returns
boolean

isHttpOnly() public ¶

isHttpOnly( )

Check if the cookie is HTTP only

Returns
boolean

isSecure() public ¶

isSecure( )

Check if the cookie is secure

Returns
boolean

toHeaderValue() public ¶

toHeaderValue( )

Returns the cookie as header value

Returns
string

withDomain() public ¶

withDomain( string $domain )

Create a cookie with an updated domain

Parameters
string $domain
Domain to set
Returns
Cake\Http\Cookie\CookieInterface

withExpired() public ¶

withExpired( )

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
Cake\Http\Cookie\CookieInterface

withExpiry() public ¶

withExpiry( DateTime|DateTimeImmutable $dateTime )

Create a cookie with an updated expiration date

Parameters
DateTime|DateTimeImmutable $dateTime
Date time object
Returns
Cake\Http\Cookie\CookieInterface

withHttpOnly() public ¶

withHttpOnly( boolean $httpOnly )

Create a cookie with HTTP Only updated

Parameters
boolean $httpOnly
HTTP Only
Returns
Cake\Http\Cookie\CookieInterface

withName() public ¶

withName( string $name )

Sets the cookie name

Parameters
string $name
Name of the cookie
Returns
Cake\Http\Cookie\CookieInterface

withNeverExpire() public ¶

withNeverExpire( )

Create a new cookie that will virtually never expire.

Returns
Cake\Http\Cookie\CookieInterface

withPath() public ¶

withPath( string $path )

Create a new cookie with an updated path

Parameters
string $path
Sets the path
Returns
Cake\Http\Cookie\CookieInterface

withSecure() public ¶

withSecure( boolean $secure )

Create a cookie with Secure updated

Parameters
boolean $secure
Secure attribute value
Returns
Cake\Http\Cookie\CookieInterface

withValue() public ¶

withValue( string|array $value )

Create a cookie with an updated value.

Parameters
string|array $value
Value of the cookie to set
Returns
Cake\Http\Cookie\CookieInterface
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs