Password protect cookie

Change the default 10-day expiration for the password protected pages cookie

zet dit in functions.php in child theme

/**

  • Filters the life span of the post password cookie.
    *
  • By default, the cookie expires 10 days from creation. To turn this
  • into a session cookie, return 0.
    *
  • @since 3.7.0
    *
  • @param int $expires The expiry time, as passed to setcookie().
    */
    add_filter( ‘post_password_expires’, ‘wpse_custom_post_password_expires’ );
    function wpse_custom_post_password_expires( $expires ) {
    return time() + 30; // Expire in 30 seconds
    }

To password protect a page in WordPress follow these simple steps.
Edit the page or post you want to password protect.
In the top left corner under the Publish option Edit the visibility.
From there select Password protected and enter a password.
That’s It, Publish and check out the change.