I am using is_user_logged_in() after a user has logged in to woocommerce (the page is a replacement for the user's woocommerce dash). This returns false, though if I reload the page it returns true.


I faced a similiar problem that user seemed to be logged out after getting redirected after login. After refreshing the page or navigating to another page user would be logged in.

A comment I saw here, Logging in redirects to correct page but shows logged out content until forced refresh, helped me to solve the problem.

I used add_query_arg to add a dummy parameter to bust browser cache, which I think was the root problem. I placed the following code inside my redirection function's conditions check,

$redirect = add_query_arg( 'redirect', time(), home_url() );
wp_redirect( $redirect );

Of course the key and the value can be anything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.