• Hi,
    I am wondering how you change the expiry time of the cookie that stores the password for a protected post.

    In wp-login.php I can see the following:

    /**
    	 * Filter 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().
    	 */
    	$expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );
    	setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH );
    
    	wp_safe_redirect( wp_get_referer() );
    	exit();

    but I do not understand how I go about changing it – I assume something I need to add to my functions.php

    Thanks for any advice.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Change password protected post cookie length’ is closed to new replies.