> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/information-functions/session_user.md).

# SESSION\_USER

## Syntax

```bnf
SESSION_USER()
```

## Description

{% tabs %}
{% tab title="Current" %}
Shows the value of [CURRENT\_USER()](/docs/server/reference/sql-functions/secondary-functions/information-functions/current_user.md) when the session was created, that is, it shows a `user@host` pair from the [mysql.global\_priv table](/docs/server/reference/system-tables/the-mysql-database-tables/mysql-global_priv-table.md), 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()](/docs/server/reference/sql-functions/secondary-functions/information-functions/user.md).
{% endtab %}
{% endtabs %}

Backward-compatible behavior can be restored by setting old mode to [SESSION\_USER\_IS\_USER](/docs/server/server-management/variables-and-modes/old_mode.md#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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.
