• Resolved repeat123

    (@repeat123)


    Hi,

    I got one page on my website that is password protected. When somebody types the password he can view that page.
    If a user comes back after some time he doesn’t need to fill in the password. He has to do this again when he cleares his browser history.

    Is it possible to make an option like ‘remember password’ or something like that. If somebody is on a public pc, anyone can view that password protected page.

    I hope it’s all clear for you guys. Thanks for your help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Not without a plugin. The password is stored on the user’s computer in a short-term cookie.

    Thread Starter repeat123

    (@repeat123)

    Ok thank you, do you know a plugin I could use for this?

    Ok, I have a question for repeat123.

    Are you trying to expire the cookie once they log out? So that no one on a public computer can view the page after the logged out user?

    Thread Starter repeat123

    (@repeat123)

    Yes mickey, thats correct.

    repeat123 wrote:

    Yes mickey, thats correct.

    Here you go:

    Put the following in your theme’s functions.php file. With a time of 0 in setcookie() forces the cookie to expire with the session.

    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);
    }

    If anyone sees any mistakes, please let me know. Thanks.

    Thread Starter repeat123

    (@repeat123)

    Thank you very much MickeyRoush! It works perfectly!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Remember password (protected pages)’ is closed to new replies.