Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Here is what I'm doing:


var_dump returns:


Why is wp_logout() not logging me out?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

wp_logout() calls clear_auth_cookie(), which expires all authorization cookies set. It doesn't change the value of the global $current_user variable. So technically you're still logged in for the duration of the script.

If you're using wp_logout in your own code, its probably best to exit or wp_redirect immediately afterwards.

share|improve this answer
None of this seems to work. After wp_logout() I have tried unset($current_user) and wp_redirect(get_bloginfo("url")); –  Jarred Mar 26 '11 at 19:38
You can call wp_set_current_user(0); after wp_logout() to manually log the user out instantly, if you need to continue executing PHP but don't want the user to be logged in... –  goldenapples Mar 27 '11 at 16:27
Couldn't get wp_redirect() to work so instead I'm using: wp_logout(); auth_redirect(); which worked perfectly for me –  Coombesy Jul 30 '12 at 9:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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