wp_get_session_token

Retrieve the current session token from the logged_in cookie.

Description

(string) wp_get_session_token(); 

Returns (string)

Token.


Usage

  1. if ( !function_exists( 'wp_get_session_token' ) ) { 
  2. require_once ABSPATH . WPINC . '/user.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_get_session_token(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/user.php  
  1. function wp_get_session_token() { 
  2. $cookie = wp_parse_auth_cookie( '', 'logged_in' ); 
  3. return ! empty( $cookie['token'] ) ? $cookie['token'] : '';