wp_clearcookie()
云策文档标注
概述
wp_clearcookie() 是一个已弃用的 WordPress 函数,用于清除认证 cookie 以注销用户。自 WordPress 2.5.0 起,建议使用 wp_clear_auth_cookie() 替代。
关键要点
- wp_clearcookie() 函数已弃用,自 WordPress 2.5.0 版本起,应改用 wp_clear_auth_cookie()。
- 该函数通过调用 wp_clear_auth_cookie() 实现清除认证 cookie 的功能,并记录弃用信息。
- 相关函数包括 wp_clear_auth_cookie()(用于移除所有认证相关 cookie)和 _deprecated_function()(用于标记函数为弃用)。
代码示例
function wp_clearcookie() {
_deprecated_function( __FUNCTION__, '2.5.0', 'wp_clear_auth_cookie()' );
wp_clear_auth_cookie();
}注意事项
- 在开发中应避免使用 wp_clearcookie(),转而使用 wp_clear_auth_cookie() 以确保兼容性和最佳实践。
- 弃用信息通过 _deprecated_function() 记录,有助于开发者识别和更新代码。
原文内容
Clears the authentication cookie, logging the user out. This function is deprecated.
Description
See also
Source
function wp_clearcookie() {
_deprecated_function( __FUNCTION__, '2.5.0', 'wp_clear_auth_cookie()' );
wp_clear_auth_cookie();
}
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Deprecated. Use wp_clear_auth_cookie() |
| 1.5.0 | Introduced. |