CakePHP
  • 文档
    • 手册
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 企业解决方案
  • 商品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与
    • 问题(Github)
    • 烘焙坊
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 新闻简报
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • 帮助与支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持
CakePHP

C CakePHP 5.1 Chiffon API

  • 项目
    • CakePHP
      • CakePHP
      • Chronos
      • Elastic Search
      • 队列
  • 版本
    • 5.1
      • 5.1
      • 5.0
      • 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

命名空间

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

接口 CookieInterface

Cookie 接口

命名空间: Cake\Http\Cookie

常量

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

    过期属性格式。

  • string
    SAMESITE_LAX ¶
    'Lax'

    SameSite 属性值:Lax

  • string
    SAMESITE_NONE ¶
    'None'

    SameSite 属性值:None

  • string
    SAMESITE_STRICT ¶
    'Strict'

    SameSite 属性值:Strict

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

    "SameSite" 属性的有效值。

方法摘要

  • getDomain() public

    获取域属性。

  • getExpiresTimestamp() public

    获取过期时间的毫秒数

  • getExpiry() public

    获取当前过期时间

  • getFormattedExpires() public

    构建报头字符串中的过期值部分

  • getId() public

    获取 cookie 的 id

  • getName() public

    获取 cookie 名称

  • getOptions() public

    获取 cookie 选项

  • getPath() public

    获取路径属性。

  • getSameSite() public

    获取 SameSite 属性。

  • getScalarValue() public

    获取 cookie 值为标量。

  • getValue() public

    获取 cookie 值

  • isExpired() public

    检查 cookie 是否在与 $time 比较时过期

  • isHttpOnly() public

    检查 cookie 是否为 HTTP only

  • isSecure() public

    检查 cookie 是否安全

  • toArray() public

    获取 cookie 数据为数组。

  • toHeaderValue() public

    以报头值形式返回 cookie

  • withDomain() public

    创建一个具有更新域的 cookie

  • withExpired() public

    创建一个新 cookie,它将从浏览器中过期/删除 cookie。

  • withExpiry() public

    创建一个具有更新过期日期的 cookie

  • withHttpOnly() public

    创建一个 HTTP Only 更新的 cookie

  • withName() public

    设置 cookie 名称

  • withNeverExpire() public

    创建一个实际上永远不会过期的新 cookie。

  • withPath() public

    创建一个具有更新路径的新 cookie

  • withSameSite() public

    创建一个具有更新 SameSite 选项的 cookie。

  • withSecure() public

    创建一个 Secure 更新的 cookie

  • withValue() public

    创建一个具有更新值的 cookie。

方法详情

getDomain() ¶ public

getDomain(): string

获取域属性。

返回
string

getExpiresTimestamp() ¶ public

getExpiresTimestamp(): int|null

获取过期时间的毫秒数

返回
int|null

getExpiry() ¶ public

getExpiry(): DateTimeInterface|null

获取当前过期时间

返回
DateTimeInterface|null

getFormattedExpires() ¶ public

getFormattedExpires(): string

构建报头字符串中的过期值部分

返回
string

getId() ¶ public

getId(): string

获取 cookie 的 id

cookie 在名称、域、路径三元组之间是唯一的。

返回
string

getName() ¶ public

getName(): string

获取 cookie 名称

返回
string

getOptions() ¶ public

getOptions(): array<string, mixed>

获取 cookie 选项

返回
array<string, mixed>

getPath() ¶ public

getPath(): string

获取路径属性。

返回
string

getSameSite() ¶ public

getSameSite(): Cake\Http\Cookie\SameSiteEnum|null

获取 SameSite 属性。

返回
Cake\Http\Cookie\SameSiteEnum|null

getScalarValue() ¶ public

getScalarValue(): string

获取 cookie 值为标量。

这将使用 json_encode() 合并 cookie 中的任何复杂数据

返回
string

getValue() ¶ public

getValue(): array|string

获取 cookie 值

返回
array|string

isExpired() ¶ public

isExpired(DateTimeInterface|null $time = null): bool

检查 cookie 是否在与 $time 比较时过期

没有过期日期的 cookie 始终返回 false。

参数
DateTimeInterface|null $time 可选

要测试的时间。默认值为 UTC 中的“现在”。

返回
bool

isHttpOnly() ¶ public

isHttpOnly(): bool

检查 cookie 是否为 HTTP only

返回
bool

isSecure() ¶ public

isSecure(): bool

检查 cookie 是否安全

返回
bool

toArray() ¶ public

toArray(): array<string, mixed>

获取 cookie 数据为数组。

返回
array<string, mixed>

toHeaderValue() ¶ public

toHeaderValue(): string

以报头值形式返回 cookie

返回
string

withDomain() ¶ public

withDomain(string $domain): static

创建一个具有更新域的 cookie

参数
string $domain

要设置的域

返回
static

withExpired() ¶ public

withExpired(): static

创建一个新 cookie,它将从浏览器中过期/删除 cookie。

这是通过将过期时间设置为一年前来完成的

返回
static

withExpiry() ¶ public

withExpiry(DateTimeInterface $dateTime): static

创建一个具有更新过期日期的 cookie

参数
DateTimeInterface $dateTime

日期时间对象

返回
static

withHttpOnly() ¶ public

withHttpOnly(bool $httpOnly): static

创建一个 HTTP Only 更新的 cookie

参数
bool $httpOnly

HTTP Only

返回
static

withName() ¶ public

withName(string $name): static

设置 cookie 名称

参数
string $name

Cookie 的名称

返回
static

withNeverExpire() ¶ public

withNeverExpire(): static

创建一个实际上永远不会过期的新 cookie。

返回
static

withPath() ¶ public

withPath(string $path): static

创建一个具有更新路径的新 cookie

参数
string $path

设置路径

返回
static

withSameSite() ¶ public

withSameSite(Cake\Http\Cookie\SameSiteEnum|string|null $sameSite): static

创建一个具有更新 SameSite 选项的 cookie。

参数
Cake\Http\Cookie\SameSiteEnum|string|null $sameSite

要为 Samesite 选项设置的值。

返回
static

withSecure() ¶ public

withSecure(bool $secure): static

创建一个 Secure 更新的 cookie

参数
bool $secure

安全属性值

返回
static

withValue() ¶ public

withValue(array|string|float|int|bool $value): static

创建一个具有更新值的 cookie。

参数
array|string|float|int|bool $value

要设置的 Cookie 的值

返回
static
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 手册
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 参与
  • 问题(Github)
  • 烘焙坊
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 新闻简报
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助与支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成