接口 CookieInterface
Cookie 接口
常量
-
stringEXPIRES_FORMAT ¶'D, d-M-Y H:i:s T'过期属性格式。
-
stringSAMESITE_LAX ¶'Lax'SameSite 属性值:Lax
-
stringSAMESITE_NONE ¶'None'SameSite 属性值:None
-
stringSAMESITE_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。
方法详情
getSameSite() ¶ public
getSameSite(): Cake\Http\Cookie\SameSiteEnum|null
获取 SameSite 属性。
返回
Cake\Http\Cookie\SameSiteEnum|nullgetScalarValue() ¶ public
getScalarValue(): string
获取 cookie 值为标量。
这将使用 json_encode() 合并 cookie 中的任何复杂数据
返回
stringisExpired() ¶ public
isExpired(DateTimeInterface|null $time = null): bool
检查 cookie 是否在与 $time 比较时过期
没有过期日期的 cookie 始终返回 false。
参数
-
DateTimeInterface|null$time 可选 要测试的时间。默认值为 UTC 中的“现在”。
返回
boolwithDomain() ¶ public
withDomain(string $domain): static
创建一个具有更新域的 cookie
参数
-
string$domain 要设置的域
返回
staticwithExpired() ¶ public
withExpired(): static
创建一个新 cookie,它将从浏览器中过期/删除 cookie。
这是通过将过期时间设置为一年前来完成的
返回
staticwithExpiry() ¶ public
withExpiry(DateTimeInterface $dateTime): static
创建一个具有更新过期日期的 cookie
参数
-
DateTimeInterface$dateTime 日期时间对象
返回
staticwithHttpOnly() ¶ public
withHttpOnly(bool $httpOnly): static
创建一个 HTTP Only 更新的 cookie
参数
-
bool$httpOnly HTTP Only
返回
staticwithName() ¶ public
withName(string $name): static
设置 cookie 名称
参数
-
string$name Cookie 的名称
返回
staticwithPath() ¶ public
withPath(string $path): static
创建一个具有更新路径的新 cookie
参数
-
string$path 设置路径
返回
staticwithSameSite() ¶ public
withSameSite(Cake\Http\Cookie\SameSiteEnum|string|null $sameSite): static
创建一个具有更新 SameSite 选项的 cookie。
参数
-
Cake\Http\Cookie\SameSiteEnum|string|null$sameSite 要为 Samesite 选项设置的值。
返回
staticwithSecure() ¶ public
withSecure(bool $secure): static
创建一个 Secure 更新的 cookie
参数
-
bool$secure 安全属性值
返回
staticwithValue() ¶ public
withValue(array|string|float|int|bool $value): static
创建一个具有更新值的 cookie。
参数
-
array|string|float|int|bool$value 要设置的 Cookie 的值
返回
static