auth_cookie_bad_hash
云策文档标注
概述
auth_cookie_bad_hash 是一个 WordPress 动作钩子,当遇到无效的身份验证 cookie 哈希时触发。它允许开发者处理 cookie 验证失败的情况,并提供了 cookie 组件的参数。
关键要点
- 这是一个 WordPress 动作钩子,用于在身份验证 cookie 哈希无效时执行自定义代码。
- 钩子传递一个参数 $cookie_elements,它是一个包含 cookie 组件的数组,如用户名、过期时间、会话令牌、哈希和方案。
- 这些组件来自客户端提供的 cookie 值,不应假设其有效性,开发者需要谨慎处理。
- 钩子与 wp_validate_auth_cookie() 函数相关,用于验证身份验证 cookie。
- 自 WordPress 2.7.0 版本引入。
代码示例
do_action( 'auth_cookie_bad_hash', $cookie_elements );注意事项
参数 $cookie_elements 中的组件(如用户名、过期时间等)直接来自客户端,可能被篡改,开发者在使用前应进行适当的验证和安全处理。
原文内容
Fires if a bad authentication cookie hash is encountered.
Parameters
$cookie_elementsstring[]-
Authentication cookie components. None of the components should be assumed to be valid as they come directly from a client-provided cookie value.
usernamestringUser’s username.expirationstringThe time the cookie expires as a UNIX timestamp.tokenstringUser’s session token used.hmacstringThe security hash for the cookie.schemestringThe cookie scheme to use.
Source
do_action( 'auth_cookie_bad_hash', $cookie_elements );
Changelog
| Version | Description |
|---|---|
| 2.7.0 | Introduced. |