You can’t modify the parameters of a filter like that, that’s not what they’re there for. In the source code it’ll look something like this:
$cookie = apply_filters( $cookie, $user_id, $expiration, $scheme, $token );
It’s explicitly looking for the value of $cookie
. If you return the value for $expiration
, things will break. The extra parameters are there so filtering can be restricted to specific situations, like only for a certain user.
However you can modify the expiration with a different approach. The function that contains the auth_cookie
filter is wp_generate_auth_cookie()
. This function appears to only be used (in core at least) by the function wp_set_auth_cookie()
. If we look at that function, we can see the auth_cookie_expiration
filter. This filter is what creates the $expiration
value that is passed to the original auth_cookie
filter.
TL;DR, use the auth_cookie_expiration
filter instead.