Forum Replies Created

Viewing 1 replies (of 1 total)
  • Forum: Hacks
    In reply to: Page Protection Password

    My own hackish solution, based on fr2632‘s function, which instead “refreshes” the cookie with $seconds time each time someone is on a specific page (probably the password-protected one), and should live through updates:

    In functions.php :

    function post_pw_sess_refresh($seconds = 900) {
    	if ( isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) ){
    		setcookie('wp-postpass_' . COOKIEHASH, $_COOKIE['wp-postpass_' . COOKIEHASH], time() + $seconds, COOKIEPATH);
    	}
    }

    In header.php : (With a $post->ID of your choice, of course)

    <?php if ($post->ID == 10){ post_pw_sess_refresh(900); } ?>

    So you kill the huge 10 day default lifetime of the original cookie, and as a bonus can keep it alive as long as you hop around in pages that call the function.

Viewing 1 replies (of 1 total)