original_string: public static function get_login_token() {
          global $CFG, $SESSION;
  
          $state = false;
  
          if (!isset($SESSION->logintoken)) {
              $SESSION->logintoken = [];
          }
  
          if (array_key_exists(self::$logintokenkey, $SESSION->logintoken)) {
              $state = $SESSION->logintoken[self::$logintokenkey];
          }
          if (empty($state)) {
              $state = self::create_login_token();
          }
  
          // Check token lifespan.
          if ($state['created'] < (time() - $CFG->sessiontimeout)) {
              $state = self::create_login_token();
          }
  
          // Return the current session login token.
          if (array_key_exists('token', $state)) {
              return $state['token'];
          } else {
              return false;
          }
      }
code: public static function get_login_token() {
          global $CFG, $SESSION;
  
          $state = false;
  
          if (!isset($SESSION->logintoken)) {
              $SESSION->logintoken = [];
          }
  
          if (array_key_exists(self::$logintokenkey, $SESSION->logintoken)) {
              $state = $SESSION->logintoken[self::$logintokenkey];
          }
          if (empty($state)) {
              $state = self::create_login_token();
          }
  
          // Check token lifespan.
          if ($state['created'] < (time() - $CFG->sessiontimeout)) {
              $state = self::create_login_token();
          }
  
          // Return the current session login token.
          if (array_key_exists('token', $state)) {
              return $state['token'];
          } else {
              return false;
          }
      }
code_tokens: public static function get_login_token ( ) { global $ CFG , $ SESSION ; $ state = false ; if ( ! isset ( $ SESSION -> logintoken ) ) { $ SESSION -> logintoken = [ ] ; } if ( array_key_exists ( self :: $ logintokenkey , $ SESSION -> logintoken ) ) { $ state = $ SESSION -> logintoken [ self :: $ logintokenkey ] ; } if ( empty ( $ state ) ) { $ state = self :: create_login_token ( ) ; } // Check token lifespan. if ( $ state [ 'created' ] < ( time ( ) - $ CFG -> sessiontimeout ) ) { $ state = self :: create_login_token ( ) ; } // Return the current session login token. if ( array_key_exists ( 'token' , $ state ) ) { return $ state [ 'token' ] ; } else { return false ; } }
docstring: Get the current login token or generate a new one.
  
  All login forms generated from Moodle must include a login token
  named "logintoken" with the value being the result of this function.
  Logins will be rejected if they do not include this token as well as
  the username and password fields.
  
  @return string The current login token.
docstring_tokens: Get the current login token or generate a new one .