public static function login($user, $sendAuthHeader) {
    if (isset($user->guid) && $user->enabled) {
      $token = self::$config['jwt_builder']($user);
      $appUrlParts = parse_url(self::$config['app_url']);
      setcookie(
          'TILMELDAUTH',
          $token,
          time() + self::$config['jwt_expire'],
          $appUrlParts['path'],
          $appUrlParts['host'],
          $appUrlParts['scheme'] === 'https',
          false // Allow JS access (for CSRF protection).
      );
      if ($sendAuthHeader) {
        header("X-TILMELDAUTH: $token");
      }
      self::fillSession($user);
      return true;
    }
    return false;
  }
public static function login($user, $sendAuthHeader) {
    if (isset($user->guid) && $user->enabled) {
      $token = self::$config['jwt_builder']($user);
      $appUrlParts = parse_url(self::$config['app_url']);
      setcookie(
          'TILMELDAUTH',
          $token,
          time() + self::$config['jwt_expire'],
          $appUrlParts['path'],
          $appUrlParts['host'],
          $appUrlParts['scheme'] === 'https',
          false // Allow JS access (for CSRF protection).
      );
      if ($sendAuthHeader) {
        header("X-TILMELDAUTH: $token");
      }
      self::fillSession($user);
      return true;
    }
    return false;
  }
public static function login ( $ user , $ sendAuthHeader ) { if ( isset ( $ user -> guid ) && $ user -> enabled ) { $ token = self :: $ config [ 'jwt_builder' ] ( $ user ) ; $ appUrlParts = parse_url ( self :: $ config [ 'app_url' ] ) ; setcookie ( 'TILMELDAUTH' , $ token , time ( ) + self :: $ config [ 'jwt_expire' ] , $ appUrlParts [ 'path' ] , $ appUrlParts [ 'host' ] , $ appUrlParts [ 'scheme' ] === 'https' , false // Allow JS access (for CSRF protection). ) ; if ( $ sendAuthHeader ) { header ( "X-TILMELDAUTH: $token" ) ; } self :: fillSession ( $ user ) ; return true ; } return false ; }
Logs the given user into the system.

@param \Tilmeld\Entities\User $user The user.
@param bool $alwaysSendAuthHeader When true, a custom header with the auth
token will be sent.
@return bool True on success, false on failure.
Logs the given user into the system .