more update on the cookie for protected pages
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 25 Feb 2016 20:18:01 +0000 (15:18 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 25 Feb 2016 20:18:01 +0000 (15:18 -0500)
functions.php

index 4a0f820..425a9eb 100644 (file)
@@ -155,16 +155,10 @@ add_image_size('glm_blocks_small', '570', '280', true);
 add_action( 'wp', 'post_pw_sess_expire' );
 function post_pw_sess_expire() {
     global $post;
-    if ($post->ID == 118 ) {
-        if ( isset( $_COOKIE['wp-postpass_' . COOKIEHASH] )
-            && isset( $_COOKIE['glm-test_' . COOKIEHASH] )
-        ) {
+    if ( $post->ID == 118 ) {
+        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, '', 0, COOKIEPATH);
-            setcookie('glm-test_' . COOKIEHASH, '', 0, COOKIEPATH);
-        }
-        if ( isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) ) {
-            setcookie('glm-test_' . COOKIEHASH, COOKIEHASH, time() + 3600, COOKIEPATH);
+            setcookie('wp-postpass_' . COOKIEHASH, $_COOKIE['wp-postpass_' . COOKIEHASH], strtotime( '+20 minutes' ), COOKIEPATH);
         }
     }
 }