mac*_*ack 19 wordpress session
如果用户(admin)在wordpress站点中处于非活动状态15分钟,我希望会话到期,
任何人都可以告诉我什么是wordpress中的默认会话到期时间?以及如何更改默认过期时间.
Rez*_*mun 59
只需在主题的functions.php中添加此代码:
add_filter('auth_cookie_expiration', 'my_expiration_filter', 99, 3);
function my_expiration_filter($seconds, $user_id, $remember){
//if "remember me" is checked;
if ( $remember ) {
//WP defaults to 2 weeks;
$expiration = 14*24*60*60; //UPDATE HERE;
} else {
//WP defaults to 48 hrs/2 days;
$expiration = 2*24*60*60; //UPDATE HERE;
}
//http://en.wikipedia.org/wiki/Year_2038_problem
if ( PHP_INT_MAX - time() < $expiration ) {
//Fix to a little bit earlier!
$expiration = PHP_INT_MAX - time() - 5;
}
return $expiration;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
55247 次 |
最近记录: |