Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_set_auth_cookie [ WordPress Function ]

wp_set_auth_cookie ( $user_id, $remember = false, $secure = '' )
Parameters:
  • (int) $user_id User ID
  • (bool) $remember Whether to remember the user
Defined at:



Sets the authentication cookies based User ID.

The $remember parameter increases the time that the cookie will be kept. The default the cookie is kept without remembering is two days. When $remember is set, the cookies will be kept for 14 days or two weeks.

Source


<?php
function wp_set_auth_cookie($user_id$remember false$secure '') {
    if ( 
$remember ) {
        
$expiration $expire time() + apply_filters('auth_cookie_expiration'1209600$user_id$remember);
    } else {
        
$expiration time() + apply_filters('auth_cookie_expiration'172800$user_id$remember);
        
$expire 0;
    }

    if ( 
'' === $secure )
        
$secure is_ssl();

    
$secure apply_filters('secure_auth_cookie'$secure$user_id);
    
$secure_logged_in_cookie apply_filters('secure_logged_in_cookie'false$user_id$secure);

    if ( 
$secure ) {
        
$auth_cookie_name SECURE_AUTH_COOKIE;
        
$scheme 'secure_auth';
    } else {
        
$auth_cookie_name AUTH_COOKIE;
        
$scheme 'auth';
    }

    
$auth_cookie wp_generate_auth_cookie($user_id$expiration$scheme);
    
$logged_in_cookie wp_generate_auth_cookie($user_id$expiration'logged_in');

    
do_action('set_auth_cookie'$auth_cookie$expire$expiration$user_id$scheme);
    
do_action('set_logged_in_cookie'$logged_in_cookie$expire$expiration$user_id'logged_in');

    
setcookie($auth_cookie_name$auth_cookie$expirePLUGINS_COOKIE_PATHCOOKIE_DOMAIN$securetrue);
    
setcookie($auth_cookie_name$auth_cookie$expireADMIN_COOKIE_PATHCOOKIE_DOMAIN$securetrue);
    
setcookie(LOGGED_IN_COOKIE$logged_in_cookie$expireCOOKIEPATHCOOKIE_DOMAIN$secure_logged_in_cookietrue);
    if ( 
COOKIEPATH != SITECOOKIEPATH )
        
setcookie(LOGGED_IN_COOKIE$logged_in_cookie$expireSITECOOKIEPATHCOOKIE_DOMAIN$secure_logged_in_cookietrue);
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics