auth_cookie
云策文档标注
概述
auth_cookie 是一个 WordPress 过滤器钩子,用于过滤认证 cookie 的内容。它允许开发者在 cookie 生成时修改其值,常用于自定义认证逻辑或安全增强。
关键要点
- 钩子名称:auth_cookie,用于过滤认证 cookie 字符串。
- 参数:包括 $cookie(cookie 字符串)、$user_id(用户 ID)、$expiration(过期时间戳)、$scheme(cookie 方案,如 'auth'、'secure_auth'、'logged_in')和 $token(用户会话令牌)。
- 用途:可结合 wp_generate_auth_cookie() 函数使用,修改 cookie 内容以适配特定需求。
- 版本历史:从 WordPress 2.5.0 引入,4.0.0 版本添加了 $token 参数。
原文内容
Filters the authentication cookie.
Parameters
$cookiestring-
Authentication cookie.
$user_idint-
User ID.
$expirationint-
The time the cookie expires as a UNIX timestamp.
$schemestring-
Cookie scheme used. Accepts
'auth','secure_auth', or'logged_in'. $tokenstring-
User’s session token used.
Source
return apply_filters( 'auth_cookie', $cookie, $user_id, $expiration, $scheme, $token );