apply_filters( ‘post_password_expires’, int $expires )

Filters the life span of the post password cookie.

Description

By default, the cookie expires 10 days from creation. To turn this into a session cookie, return 0.

Parameters

$expiresint
The expiry time, as passed to setcookie().

Source

$expire  = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );

Changelog

VersionDescription
3.7.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Allows you to limit the cookie validity time either to a value passed as a parameter or to the session itself.

    function Modif_expir_cookie( $time ) { 
      return time() + 600 ;  // 10 mn
      // for 5 minutes :  
      // return time() + 300;  in this case 60 * 5 
      // return 0; set cookie to expire at the end of the session
    }
    add_filter('post_password_expires', 'Modif_expir_cookie' );

You must log in before being able to contribute a note or feedback.