Set Session Time Limit for Password Protected Posts

The reason is when you execute this code

setcookie('wp-postpass_' . COOKIEHASH, '', 0, COOKIEPATH);

It will reset your post password cookie to blank ”, so it just work once To solve this you need to assign the original cookie and extend the timeout, like this

setcookie('wp-postpass_' . COOKIEHASH, $_COOKIE['wp-postpass_' . COOKIEHASH], time() + 60 * 5, COOKIEPATH);

Hope this help

Leave a Comment