Files
core/lib/doc/dever-api-cookie.md
T
2026-11-03 03:32:07 +00:00

45 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Cookie
Cookie 写入会检查外部 Origin;Secret Cookie 使用带版本的字节编码。
## dever.api.SameSite
限定浏览器跨站发送 Cookie 的策略。
分支:
- `Strict`:仅同站发送
- `Lax`:同站请求和安全的顶层导航
- `None`:允许跨站,必须同时启用 Secure
## dever.api.CookieOptions
属性控制浏览器发送范围,不用于服务端授权。
字段:
- `path`:路径
- `domain`:可选域
- `same_site`:浏览器跨站发送策略
- `secure`:只通过 HTTPS 发送
- `http_only`:禁止脚本读取
- `max_age`:可选秒数,零表示删除
## dever.api.secureCookieOptions
默认使用路径 /、SameSite=Lax、Secure 和 HttpOnly,不指定域和有效期。
## dever.api.cookie
读取普通文本 Cookie,认证 Cookie 或 Secret 编码不能读为 Text。
## dever.api.secretCookie
读取带 v1 前缀的无填充 base64url 字节;其他格式视为缺席。
## dever.api.setCookie
暂存普通 Cookie,业务或编码失败时不发布。
## dever.api.setSecretCookie
秘密 Cookie 必须保留 Secure 和 HttpOnly。