I’m trying to configure the WordPress cookie expiration time, but for some reason it’s not working. I went here:
And put the following hook based on the doc:
function init() {
// ...
$expiration = 60;
apply_filters( 'auth_cookie_expiration', $expiration );
}
This code is called from a hook in my plugin’s constructor:
add_action( 'init', array( $this, 'init' ) );
And I have verified that it runs.
I expected this to produce a cookie that expires in 60 seconds, but it doesn’t. Instead it sets a regular expiration time of 48 hours (WP default). I suspect this might be because when the user actually logs in, it doesn’t create this expiration date, and running this function later has no effect. I haven’t yet figured out how to make it work though. Any help appreciated.