> For the complete documentation index, see [llms.txt](https://mile-hi-labs.gitbook.io/react-session/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mile-hi-labs.gitbook.io/react-session/api-documentation/session.md).

# Session

## Properties

| Attribute | Type    |
| --------- | ------- |
| user      | object  |
| token     | string  |
| params    | object  |
| modelName | string  |
| loaded    | boolean |

These properties come standard with the session object and will update accordingly when the session is authenticated so you can access them from anywhere in your application.&#x20;

## loadSession()

`async session.loadSession(store, modelName, modelId, token, params)`

The session uses the `loadSession()` method to load the session on initial page load or via the other convenience methods in the object. This method is only called if a `userId` and `token` are present in LocalStorage.&#x20;

## updateSession()

`async session.updateSession()`

The session uses `updateSession()` to fetch a fresh session from the server using the credentials already stored in LocalStorage. Use this method if you want to update the session object without logout / login.

## authenticate()

`async session.authenticate(modelName, data)`

The Session uses the `authenticate()` method to store your user in LocalStorage and persist them across multiple sessions. You are able to customize the model that's being authenticated though it defaults to 'user'.&#x20;

```javascript
await session.authenticate('user', user)
```

## logout()

`async session.logout()`

The Session uses the `logout()` method to clear out LocalStorage, and remove the current user from the session. You're then responsible for any work after that.&#x20;

```
await session.logout()
```

## authenticated()

`session.authenticated()`

The Session uses the `authenticated()` method to check whether the current user is logged in. This can be used in your router to restrict access to certain routes like so:

```javascript
```


---

# 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://mile-hi-labs.gitbook.io/react-session/api-documentation/session.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.
