/** * Store WP authentication cookie params in the settings for future use * * Since the plugin needs to duplicate the WP cookie settings, we need to * store them for future use, as on this stage we do not authenticate * the user with the second factor yet - this will happen in a moment. * * @param string $auth_cookie Set cookie * @param int $expire Whether the cookie is a session or permanent one * @param int $expiration Expiration date (timestamp) * @param id $user_id Logged in user's WP ID * @param string $scheme Whether the cookie is secure * @return void */ function rublon2factor_store_auth_cookie_params($auth_cookie, $expire, $expiration, $user_id = null, $scheme) { // Deprecated? if ($user_id) { $user = get_user_by('id', $user_id); $secure = $scheme == 'secure_auth'; if ($user) { $secure_logged_in_cookie = apply_filters('secure_logged_in_cookie', false, $user_id, $secure); $cookieParams = array('secure' => $secure, 'remember' => $expire > 0, 'logged_in_secure' => $secure_logged_in_cookie); $settings = RublonHelper::getSettings(); $settings['wp_cookie_params'] = $cookieParams; $settings['wp_cookie_expiration'] = array('expire' => $expire, 'expiration' => $expiration); RublonHelper::saveSettings($settings); } $flag = RublonHelper::flag($user, RublonHelper::TRANSIENT_FLAG_UPDATE_AUTH_COOKIE); if ($flag === RublonHelper::YES) { RublonCookies::setAuthCookie($user); } } }