登录cookie的名称为\'wp-postpass_\' . COOKIEHASH
哪里COOKIEHASH
在wp-config.php
或在中wp-includes/default-constants.php function wp_cookie_constants()
.
该值为:
$hasher->HashPassword( wp_unslash( $_POST[\'post_password\'] ) )
无论何时更改密码,cookie都不再匹配,并且
is_user_logged_in()
必须返回
FALSE
.
在用户更改密码后,立即将其发送到登录屏幕
或在保存密码后对用户进行身份验证:
require_once ABSPATH . \'wp-includes/class-phpass.php\';
$hasher = new PasswordHash( 8, true );
$expire = apply_filters( \'post_password_expires\', time() + 10 * DAY_IN_SECONDS );
setcookie( \'wp-postpass_\' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST[\'post_password\'] ) ), $expire, COOKIEPATH );