2

I have to make sure, that the Wordpress cookie set after successful log in, "wordpress_logged_in_[salt-sth]" is set to be available for secure connections only.

It looks like that it´s a filter used in pluggable.php, line 653

$secure_logged_in_cookie = apply_filters('secure_logged_in_cookie', false, $user_id, $secure);

How can I set it to secure, WITHOUT modifiyng the wordpress core files? If I modify the core (set to true) - it´s not possible to logout anymore...

Thank U!

1
  • In addition to the question above: Cookie is secure now, but the user is logged out automatically directly after loggin in. How can I prevent this? Thanks again!
    – user19512
    Commented Aug 21, 2012 at 14:55

1 Answer 1

2

The advantage of a filter is that you can change a value without modifying core WP files. The filter you list:

$secure_logged_in_cookie = apply_filters('secure_logged_in_cookie', false, $user_id, $secure);

Passes in three values. You just need to build a function that accepts those three values and returns true (or just returns true by default.

This function, for example, merely returns true for whatever value is passed in to that filter:

add_filter( 'secure_logged_in_cookie', '__return_true' );
2
  • Great, thx for your fast reply - I understand and will try this!
    – Markus
    Commented Aug 21, 2012 at 14:18
  • Thank you! I was digging around in pluggable.php to see where the cookies were getting set and found the apply_filter call. This is perfect, and today I learned about WP's __return_true function
    – phatskat
    Commented Feb 4, 2015 at 14:19

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.