---
id: auth-setsession
title: 'setSession()'
slug: /auth-setsession
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---

import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'

Sets the session data from refresh_token and returns current session or an error if the refresh_token is invalid.

```js
  const { data, error } = supabase.auth.setSession(refresh_token)
}
```

## Parameters

<ul className="method-list-group">
  
<li className="method-list-item">
  <h4 className="method-list-item-label">
    <span className="method-list-item-label-name">
      refresh_token
    </span>
    <span className="method-list-item-label-badge required">
      required
    </span>
    <span className="method-list-item-validation">
      <code>string</code>
    </span>
  </h4>
  <div class="method-list-item-description">

The refresh token returned by gotrue.

  </div>
  
</li>

</ul>

## Examples

### Basic example.

Sets the session data from refresh_token and returns current session or an error if the refresh_token is invalid.

```js
  const { data, error } = supabase.auth.setSession(refresh_token)
}
```
