1

i use wordpress 3.9.2 and i read a lot of article and Q about clear cookies but some of them is too old ( for wp 3.4 and wp-pass with different code) or not solve my problem

i have some password protected pages and posts

they work well and wants password for see them , but after i enter password and open a protected post or pages

they will not act like a protected page anymore !! they are just like normal posts !!

it` too bad for me cause maybe my customers that have these pass open these pages in coffee net or somewhere like that !!

i read some post about clear cookie after a few min but they are not obvious and they are for wp 3.4 ( wp-pass.php)

i found this on wp-login: $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );

but no clue it`s what i need or not and how can i define a time for example 5 minutes !

i have no user login in my site and the password protected is nice for me .

it will be Great if there is a way to clear cookie or cache after close the window of browsers or a few minutes after entering pages or posts ?

1 Answer 1

2

Yes it seems that the post_password_expires filter is what you are looking for. According to the documentation you just need to add

function wpse166590_cockie_timeout($timeout) {
   return time() + 5 * 60; // 5 minute in seconds
}

add_filter('post_password_expires','wpse166590_cockie_timeout');
2
  • thanks so much i put your code in my function.php but now when i enter password on my page it`s act like my pass is wrong and password box load again i remove your code and the password pages works well again !! what wrong ??
    – Arioman
    Oct 27, 2014 at 16:42
  • sorry, me bad, updating the answer Oct 27, 2014 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.