Requests_Cookie_Jar
云策文档标注
概述
Requests_Cookie_Jar 是 WordPress 中用于管理 Cookie 的类,作为 Cookie 持有对象,提供了一系列方法来处理 HTTP 请求和响应中的 Cookie 操作。
关键要点
- 核心功能:存储和管理 Cookie,支持在请求前添加 Cookie 头、在重定向前解析响应中的 Cookie。
- 主要方法:包括构造函数 __construct、before_redirect_check、before_request、getIterator、normalize_cookie 等,用于 Cookie 的创建、标准化和迭代访问。
- 兼容性:提供 normalizeCookie 方法作为已弃用的别名,确保向后兼容。
- 数组访问接口:实现 offsetExists、offsetGet、offsetSet、offsetUnset 方法,允许以数组方式操作 Cookie 项。
- 钩子注册:register 方法用于将 Cookie 处理器注册到请求的钩子系统中。
原文内容
Cookie holder object
Methods
| Name | Description |
|---|---|
| Requests_Cookie_Jar::__construct | Create a new jar |
| Requests_Cookie_Jar::before_redirect_check | Parse all cookies from a response and attach them to the response |
| Requests_Cookie_Jar::before_request | Add Cookie header to a request if we have any |
| Requests_Cookie_Jar::getIterator | Get an iterator for the data |
| Requests_Cookie_Jar::normalize_cookie | Normalise cookie data into a Requests_Cookie |
| Requests_Cookie_Jar::normalizeCookie | Normalise cookie data into a Requests_Cookie — deprecated |
| Requests_Cookie_Jar::offsetExists | Check if the given item exists |
| Requests_Cookie_Jar::offsetGet | Get the value for the item |
| Requests_Cookie_Jar::offsetSet | Set the given item |
| Requests_Cookie_Jar::offsetUnset | Unset the given header |
| Requests_Cookie_Jar::register | Register the cookie handler with the request’s hooking system |