auth_cookie_expiration
Filter HookDescription
Filters the duration of the authentication cookie expiration period.Hook Information
File Location |
wp-includes/pluggable.php
View on GitHub
|
Hook Type | Filter |
Line Number | 1006 |
Hook Parameters
Type | Name | Description |
---|---|---|
int
|
$length
|
Duration of the expiration period in seconds. |
int
|
$user_id
|
User ID. |
bool
|
$remember
|
Whether to remember the user login. Default false. $expiration = time() + apply_filters( 'auth_cookie_expiration', 14 * DAY_IN_SECONDS, $user_id, $remember ); /* Ensure the browser will continue to send the cookie after the expiration time is reached. Needed for the login grace period in wp_validate_auth_cookie(). |
Usage Examples
Basic Usage
<?php
// Hook into auth_cookie_expiration
add_filter('auth_cookie_expiration', 'my_custom_filter', 10, 3);
function my_custom_filter($length, $user_id, $remember) {
// Your custom filtering logic here
return $length;
}
Source Code Context
wp-includes/pluggable.php:1006
- How this hook is used in WordPress core
<?php
1001 * Needed for the login grace period in wp_validate_auth_cookie().
1002 */
1003 $expire = $expiration + ( 12 * HOUR_IN_SECONDS );
1004 } else {
1005 /** This filter is documented in wp-includes/pluggable.php */
1006 $expiration = time() + apply_filters( 'auth_cookie_expiration', 2 * DAY_IN_SECONDS, $user_id, $remember );
1007 $expire = 0;
1008 }
1009
1010 if ( '' === $secure ) {
1011 $secure = is_ssl();
PHP Documentation
<?php
/**
* Filters the duration of the authentication cookie expiration period.
*
* @since 2.8.0
*
* @param int $length Duration of the expiration period in seconds.
* @param int $user_id User ID.
* @param bool $remember Whether to remember the user login. Default false.
*/
$expiration = time() + apply_filters( 'auth_cookie_expiration', 14 * DAY_IN_SECONDS, $user_id, $remember );
/*
* Ensure the browser will continue to send the cookie after the expiration time is reached.
* Needed for the login grace period in wp_validate_auth_cookie().
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/pluggable.php
Related Hooks
Related hooks will be displayed here in future updates.