• About WordPress
    • About WordPress
    • WordPress.org
    • Documentation
    • Support
    • Feedback
  • Log In
  • Register

WordPress.org

  • Showcase
  • Learn
  • Themes
  • Plugins
  • Mobile
  • Support
    • Documentation
    • Forums
  • Get Involved
    • Five for the Future
  • About
  • Blog
  • Hosting
  • Get WordPress

Code Reference

Skip to content
Filter by type:
Search
Browse: Home / Reference / Hooks / post_password_expires

apply_filters( 'post_password_expires', int $expires )

Filters the life span of the post password cookie.

Contents

  • Description
  • Parameters
  • Source
  • Changelog
  • User Contributed Notes

Description #Description

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


Top ↑

Parameters #Parameters

$expires

(int) The expiry time, as passed to setcookie().


Top ↑

Source #Source

File: wp-login.php

View on Trac


Top ↑

Changelog #Changelog

Changelog
Version Description
3.7.0 Introduced.

Top ↑

User Contributed Notes #User Contributed Notes

  1. Skip to note 1 content
    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note
    Contributed by wplmillet — 1 year ago

    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' );
    
    Log in to add feedback

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

  • About
  • Blog
  • Hosting
  • Donate
  • Support
  • Developers
  • Get Involved
  • Learn
  • Showcase
  • Plugins
  • Themes
  • WordCamp
  • WordPress.TV
  • BuddyPress
  • bbPress
  • WordPress.com
  • Matt
  • Privacy
  • Public Code
  • @WordPress
  • WordPress

Code is Poetry.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.