From 77ed4d9e5658336374dcb8d3bc15198e8652a06c Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 24 Aug 2017 08:41:11 -0400 Subject: [PATCH] Setting time limit for the password pages. If the page is password protected then set the timeout for the cookie to 60 minutes. --- functions.php | 10 ++++++++++ style.css | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/functions.php b/functions.php index b159b2b..6eaf7e7 100644 --- a/functions.php +++ b/functions.php @@ -169,4 +169,14 @@ function glm_get_header() { add_action('wp_enqueue_scripts', 'glm_site_scripts'); +add_action( 'wp', 'post_pw_sess_expire' ); +function post_pw_sess_expire() { + global $post; + if ( post_password_required() ) { + if ( isset( $_COOKIE['wp-postpass_' . COOKIEHASH] )) { + // Setting a time of 0 in setcookie() forces the cookie to expire with the session + setcookie('wp-postpass_' . COOKIEHASH, $_COOKIE['wp-postpass_' . COOKIEHASH], strtotime( '+60 minutes' ), COOKIEPATH); + } + } +} ?> diff --git a/style.css b/style.css index cf1a3ca..77ede02 100644 --- a/style.css +++ b/style.css @@ -3,5 +3,5 @@ Theme Name: Adeline-Construction Author: Gaslight Media Author URI: http://www.gaslightmedia.com Description: A theme for Adeline Construction -Version: 1.0.3 +Version: 1.0.4 */ -- 2.17.1