WordPress.org

Make WordPress Core

Changeset 6529


Ignore:
Timestamp:
12/31/2007 05:50:32 PM (10 years ago)
Author:
ryan
Message:

Separate cookie generation from cookie set. Introduce wp_generate_auth_cookie(). see #5367

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/pluggable.php

    r6486 r6529  
    358358endif;
    359359
     360if ( !function_exists('wp_generate_auth_cookie') ) :
     361function wp_generate_auth_cookie($user_id, $expiration) {
     362    $user = get_userdata($user_id);
     363
     364    $key = wp_hash($user->user_login . $expiration);
     365    $hash = hash_hmac('md5', $user->user_login . $expiration, $key);
     366
     367    $cookie = $user->user_login . '|' . $expiration . '|' . $hash;
     368
     369    return apply_filters('auth_cookie', $cookie, $user_id, $expiration);
     370}
     371endif;
     372
    360373if ( !function_exists('wp_set_auth_cookie') ) :
    361374function wp_set_auth_cookie($user_id, $remember = false) {
     
    369382    }
    370383
    371     $key = wp_hash($user->user_login . $expiration);
    372     $hash = hash_hmac('md5', $user->user_login . $expiration, $key);
    373 
    374     $cookie = $user->user_login . '|' . $expiration . '|' . $hash;
     384    $cookie = wp_generate_auth_cookie($user_id, $expiration);
    375385
    376386    do_action('set_auth_cookie', $cookie, $expire);
Note: See TracChangeset for help on using the changeset viewer.