# getUserLogin

Get the current logged in user.

{% hint style="success" %}
There is no login or logout API in Cortex. Instead, users are required to login through the [EMOTIV Launcher](https://emotiv.gitbook.io/emotiv-launcher/).
{% endhint %}

## Parameters

This method has no parameter.

## Result

The result is an array of objects, each object describes a logged in user. If no user is logged in, then the result is an empty array.

Please note that currently, Cortex is a single user system. Only one user can login at a time, so the result contains at most one object.

The user object includes these fields:&#x20;

| Name               | Type                    | Description                                                                                            |
| ------------------ | ----------------------- | ------------------------------------------------------------------------------------------------------ |
| username           | `string`                | The EmotivID of the user                                                                               |
| currentOSUId       | `string`                | The id of the current OS account                                                                       |
| currentOSUsername  | `string`                | The user name for currentOSUId                                                                         |
| loggedInOSUId      | `string`                | The id of the OS account used to login in EMOTIV Launcher                                              |
| loggedInOSUsername | `string`                | The user name for loggedInOSUId                                                                        |
| lastLoginTime      | `string (ISO datetime)` | <p>When this user logged in for the last time.</p><p><em>This field was added in Cortex 2.3.0</em></p> |

If currentOSUId is equal to loggedInOSUId, then the user is already logged in and can work with Cortex.\
If currentOSUId is different from loggedInOSUId, then a user is logged into Cortex, but from a different OS account. So the user of the current OS account cannot work with Cortex, and must check EMOTIV Launcher.

## Examples

### No user is logged in

{% tabs %}
{% tab title="Request" %}

```javascript
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getUserLogin"
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": []
}
```

{% endtab %}
{% endtabs %}

### A user is logged in from the current OS account

{% tabs %}
{% tab title="Request" %}

```javascript
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getUserLogin"
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": [{
        "currentOSUId":"501",
        "currentOSUsername":"jsnow",
        "lastLoginTime": "2019-11-28T12:09:17.300+07:00",
        "loggedInOSUId":"501",
        "loggedInOSUsername":"jsnow",
        "username":"jon.snow"
    }]
}
```

{% endtab %}
{% endtabs %}

### A user is logged in from another OS account

The application is connected to Cortex that belongs to the OS account `501/jsnow`. But someone has already logged in to Cortex from OS account `502/astark` with the EmotivID `aria.stark`. So, the application cannot work with Cortex.

{% tabs %}
{% tab title="Request" %}

```javascript
{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "getUserLogin"
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": [{
        "currentOSUId":"501",
        "currentOSUsername":"jsnow",
        "lastLoginTime": "2019-11-28T12:09:17.300+07:00",
        "loggedInOSUId":"502",
        "loggedInOSUsername":"astark",
        "username":"aria.stark"
    }]
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://emotiv.gitbook.io/cortex-api/authentication/getuserlogin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
