Title: post_password_expires
Published: April 25, 2014
Last modified: August 20, 2026

---

# apply_filters( ‘post_password_expires’, int $expires )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/post_password_expires/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/hooks/post_password_expires/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/post_password_expires/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/hooks/post_password_expires/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/post_password_expires/?output_format=md#user-contributed-notes)

Filters the life span of the post password cookie.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/post_password_expires/?output_format=md#description)󠁿

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/post_password_expires/?output_format=md#parameters)󠁿

 `$expires`int

The expiry time, as passed to setcookie().

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/post_password_expires/?output_format=md#source)󠁿

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

[View all references](https://developer.wordpress.org/reference/files/wp-login.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-login.php#L781)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-login.php#L781-L781)

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/post_password_expires/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.7.0](https://developer.wordpress.org/reference/since/3.7.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/post_password_expires/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/hooks/post_password_expires/?output_format=md#comment-content-3630)
 2.   [Laurent Millet](https://profiles.wordpress.org/wplmillet/)  [  7 years ago  ](https://developer.wordpress.org/reference/hooks/post_password_expires/#comment-3630)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fpost_password_expires%2F%23comment-3630)
    Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fpost_password_expires%2F%23comment-3630)
 4. Allows you to limit the cookie validity time either to a value passed as a parameter
    or to the session itself.
 5.     ```php
        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' );
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fpost_password_expires%2F%3Freplytocom%3D3630%23feedback-editor-3630)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fpost_password_expires%2F)
before being able to contribute a note or feedback.