---
title: Non-Logged in Users in .init()
slug: infra/non-logged-in-users-in-init
createdAt: 2021-08-30T03:57:40.000Z
---

## Introduction

In `.init()`, if `username=null`, the flow below determines how Socratease proceeds. There are two further parameters in the session\_authentication key that determine how Socratease handles such sessions:

- With `allow_unauthenticated_sessions=false`, the Socratease library will return a 401 error
- With `remember_unauthenticated_sessions=true`, even if the user closes tabs or the browser when they load your property, Socratease will restore their session.

## Code

```javascript
const payload = {
    'username': null,
    'session_authentication': {
        'allow_unauthenticated_sessions': true,
        'remember_unauthenticated_sessions': false
    }
}
```

## The Flow

```mermaid
graph TD;
    A{username=null?}
    A --> |No | A1[Create/load user with given username]
    A1 --> G[return is_registered=true]
    G --> B[Store jwt inside React]
    A --> |Yes | C{allowUnauthenticatedSessions?}
    C --> |No | D[Return 401]
    C --> |Yes | E[Create user with random username]
    E --> I[returns is_registered=false]
    I --> J{rememberUnauthenticatedSessions?}
    J --> |Yes | K[Store jwt as cookie]
    J --> |No |H1[Store jwt as sessionVariable]
```



