钩子文档

secure_signon_cookie

💡 云策文档标注

概述

secure_signon_cookie 是一个 WordPress 过滤器钩子,用于控制是否在用户登录时使用安全 cookie。它允许开发者基于登录凭据动态调整 cookie 的安全设置。

关键要点

  • secure_signon_cookie 过滤器用于修改登录过程中是否启用安全 cookie 的布尔值。
  • 该钩子接收两个参数:$secure_cookie(布尔值,表示是否使用安全 cookie)和 $credentials(数组,包含用户登录数据如用户名、密码和记住我选项)。
  • 常用于 wp_signon() 函数中,以增强登录安全性或根据特定条件调整 cookie 行为。

代码示例

$secure_cookie = apply_filters( 'secure_signon_cookie', $secure_cookie, $credentials );

注意事项

  • 此钩子自 WordPress 3.1.0 版本引入,确保在兼容版本中使用。
  • 修改 $secure_cookie 参数时需谨慎,不当设置可能影响登录安全性和用户体验。

📄 原文内容

Filters whether to use a secure sign-on cookie.

Parameters

$secure_cookiebool
Whether to use a secure sign-on cookie.
$credentialsarray
Array of entered sign-on data.

  • user_login string
    Username.
  • user_password string
    Password entered.
  • remember bool
    Whether to 'remember' the user. Increases the time that the cookie will be kept. Default false.

Source

$secure_cookie = apply_filters( 'secure_signon_cookie', $secure_cookie, $credentials );

Changelog

Version Description
3.1.0 Introduced.