admin管理员组文章数量:1332890
In WordPress, is there anything on a server that may inhibit wp_set_auth_cookie()
and/or is_user_logged_in()
from working correctly?
I've had this functionality working for a while, until today. No code changes in this area. Possible server settings? The functionality still works on my dev server at home, but not the live hosted server.
Code snippet hooked to 'init' after some logic which sets the $uid
:
wp_clear_auth_cookie();
wp_set_auth_cookie( $uid, false, true );
wp_set_current_user( $uid );
I then redirect to a page where user can confirm if they're on a trusted device:
wp_safe_redirect( $redirect_url );
In the main part of the page (called via shortcode), the following logic then fails:
if ( ! is_user_logged_in() ) {
return '<p>You must be logged in to view this page.</p>';
}
While this used to work fine, it doesn't work now. It continues to work fine on my home dev server.
Is it possible there is some server setting now interfering?
In WordPress, is there anything on a server that may inhibit wp_set_auth_cookie()
and/or is_user_logged_in()
from working correctly?
I've had this functionality working for a while, until today. No code changes in this area. Possible server settings? The functionality still works on my dev server at home, but not the live hosted server.
Code snippet hooked to 'init' after some logic which sets the $uid
:
wp_clear_auth_cookie();
wp_set_auth_cookie( $uid, false, true );
wp_set_current_user( $uid );
I then redirect to a page where user can confirm if they're on a trusted device:
wp_safe_redirect( $redirect_url );
In the main part of the page (called via shortcode), the following logic then fails:
if ( ! is_user_logged_in() ) {
return '<p>You must be logged in to view this page.</p>';
}
While this used to work fine, it doesn't work now. It continues to work fine on my home dev server.
Is it possible there is some server setting now interfering?
Share Improve this question asked Nov 21, 2024 at 2:47 gazergazer 214 bronze badges1 Answer
Reset to default 0It looks like this was a cookie issue on my browsers.
Clearing cookies and caches on my troublesome browsers helped this to work as expected.
本文标签: Wordpress server preventing wpsetauthcookie() from working correctlyStack Overflow
版权声明:本文标题:Wordpress: server preventing wp_set_auth_cookie() from working correctly? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742317026a2452025.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论