• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress core a2z

WordPress core a2z

WordPress core only

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / wp_set_auth_cookie() – Sets the authentication cookies based on user ID.

You appear to be a bot. Output may be restricted

Description

Sets the authentication cookies based on 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.

Usage

wp_set_auth_cookie( $user_id, $remember, $secure, $token );

Parameters

$user_id
( int ) required – User ID.
$remember
( bool ) optional – Whether to remember the user.
$secure
( bool|string ) optional – Whether the auth cookie should only be sent over HTTPS. Default is an empty string which means the value of is_ssl() will be used.
$token
( string ) optional – Optional. User's session token to use for this cookie.

Returns

void

Source

File name: wordpress/wp-includes/pluggable.php
Lines:

101 to 120 of 120
    do_action( 'set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in', $token );

    
/**
 * Allows preventing auth cookies from actually being sent to the client.
 *
 * @since 4.7.4
 *
 * @param bool $send Whether to send auth cookies to the client.
 */
    if ( ! apply_filters( 'send_auth_cookies', true ) ) {
      return;
    }

    setcookie( $auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true );
    setcookie( $auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true );
    setcookie( LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true );
    if ( COOKIEPATH != SITECOOKIEPATH ) {
      setcookie( LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true );
    }
  }
 
« Previous [1] [2]

 View on GitHub View on Trac

Published: 25th November 2019 | Last updated: 2nd April 2020

Primary Sidebar

Information

Function name: wp_set_auth_cookie
Plugin ref: WordPress
Version: 5.6
Sourcefile: wp-includes/pluggable.php
File ref: wp-includes/pluggable.php
Deprecated?: No
API Letters: A,C,S,W

Footer

WP-a2z
WordPress core a2z
WordPress core only
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  core.wp-a2z.org
© Copyright WP-a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites