# SESSION\_USER

## Syntax

```sql
SESSION_USER()
```

## Description

{% tabs %}
{% tab title="Current" %}
Shows the value of [CURRENT\_USER()](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/current_user) when the session was created, that is, it shows a `user@host` pair from the [mysql.global\_priv table](https://mariadb.com/docs/server/reference/system-tables/the-mysql-database-tables/mysql-global_priv-table), like `CURRENT_USER()`, but unlike `CURRENT_USER()` it will not change inside stored routines and views. This is SQL Standard behavior for the `SESSION_USER` function.
{% endtab %}

{% tab title="< 11.7" %}
`SESSION_USER()` is a synonym for [USER()](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/user).
{% endtab %}
{% endtabs %}

Backward-compatible behavior can be restored by setting old mode to [SESSION\_USER\_IS\_USER](https://mariadb.com/docs/server/server-management/variables-and-modes/old_mode#session_user_is_user).

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}


---

# 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://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/session_user.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.
