WordPress.org

Forums

PW Protected page don't ask for PW when... (2 posts)

  1. Kolsyra
    Member
    Posted 1 year ago #

    Hi,

    I have added this code:

    add_action( 'wp', 'post_pw_sess_expire' );
        function post_pw_sess_expire() {
        if ( isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) )
        // Setting a time of 0 in setcookie() forces the cookie to expire with the session
        setcookie('wp-postpass_' . COOKIEHASH, '', 0, COOKIEPATH);
    }

    into my functions.php and i t works fine when I click another page and then click the protected page again but if I use the back arrow in my browser it does not ask for the password again.

    Can this be achived in any way?

    /Kolsyra

  2. Brandon Dove
    Member
    Posted 1 year ago #

    Hi Kolsyra,

    This is a browser limitation. When you navigate backwards via browser history (e.g. clicking the back button), the browser remembers the state of the page when you left it rather than querying the server for the page again.

    Fixing this issue would likely require more theme customization via javascript to recognize that the visit is coming from a backwards navigation and then some more php and javascript customization to refresh the page or something else like that.

Topic Closed

This topic has been closed to new replies.

About this Topic