I want cookies for password protected pages in Wordpress to expire when the browser window closes. I've tried the following in my functions.php file with no luck:
function custom_password_cookie_expiry( $expires ) {
return 0; // Make it a session cookie
}
add_filter( 'post_password_expires', 'custom_password_cookie_expiry' );
Any help would be greatly appreciated
This problem had been solved here. Please see the link:
function wpse_191369_post_password_expires() {
return time() + 10; // Expire in 10 seconds
}
add_filter( 'post_password_expires', 'wpse_191369_post_password_expires' );
For more details: