I would like to better understand how WordPress login / logout cookies work.

In my case I have a page that allows you to perform various operations.

To see if the user is not logged in I perform the following operation:

<?php if (! is_user_logged_in ()) { ?>

In case you are not logged in, I show you the login and registration.

In the event that he is logged in, I show him a page with a button to change accounts which will then log out and take the user back to the first selection (ie login and registration).

If I log out to change accounts, the result of the first selection is displayed correctly.

But if I log in or register and go ahead and then go back I always find myself on the login and registration page while I should be on the page to log out.

I hope I have explained myself well, if you have any questions, please ask.

I conclude by saying: is there therefore a code that clears the caches and that allows me to correctly visualize the previous page of the login just made?

Otherwise I would have to perform another redirect and for the user experience it would not be the best.

Best regards.

Your Answer

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

Browse other questions tagged or ask your own question.