You should be using add_filter( ... )
, not apply_filters( ... )
:
/**
* 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
}