> For the complete documentation index, see [llms.txt](https://docs.does.qa/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.does.qa/guides/reuse-a-login-session.md).

# Reuse a login session

Logging in on every Test Case slows a suite and can trip rate limits on the application. Log in once in a parent Flow, store the session data, then pass it into other Flows so they start already signed in.

```mermaid
flowchart TD
  child["Child: Open then Set cookie or storage"] --> parent["Parent: login then Store session"]
  parent --> run["DoesQA Run with Values"]
  run --> childApply["Child applies session and continues"]
```

Use the **Flow Builder** for this walkthrough.

To reuse the same login *steps* in many Flows without sharing a live session, use a [Step Group](/better-coverage/reuse-steps-with-step-groups.md) instead.

## What you need

* A login URL and credentials as [Values](/values/value-store.md)
* At least one child Flow that should start signed in (create it before the parent calls it)
* The cookie or storage key your application uses after login

## Build the child Flow first

Each child Run gets a fresh browser. It must apply the session data the parent will pass in.

{% stepper %}
{% step %}

## Open the application

Start with [**Open**](/test-steps/starter/open.md). Point it at a page in your application.
{% endstep %}

{% step %}

## Set the session data

Add the matching **Data** step for how your app keeps the session:

| After login, the app uses | Set it with                                                      |
| ------------------------- | ---------------------------------------------------------------- |
| A cookie                  | [**Set cookie**](/test-steps/data/set-cookie.md)                 |
| `localStorage`            | [**Set localStorage**](/test-steps/data/set-localstorage.md)     |
| `sessionStorage`          | [**Set sessionStorage**](/test-steps/data/set-sessionstorage.md) |

In the value field, type `$` and pick the Value name the parent will pass, such as `$auth_token`.
{% endstep %}

{% step %}

## Continue the journey

Add the steps that assume a signed-in user, such as opening a dashboard and checking content.
{% endstep %}
{% endstepper %}

## Build the parent Flow

{% stepper %}
{% step %}

## Open the sign-in page

Start with [**Open**](/test-steps/starter/open.md). Point it at your login URL.
{% endstep %}

{% step %}

## Complete login

Add [**Set value**](/test-steps/action/set-value.md) and [**Touch**](/test-steps/action/touch.md) (or your usual login steps) until the session is established.
{% endstep %}

{% step %}

## Store the session data

Add the matching **Store** step:

| Source           | Step                                                                 |
| ---------------- | -------------------------------------------------------------------- |
| Cookie           | [**Store cookie**](/test-steps/data/store-cookie.md)                 |
| `localStorage`   | [**Store localStorage**](/test-steps/data/store-localstorage.md)     |
| `sessionStorage` | [**Store sessionStorage**](/test-steps/data/store-sessionstorage.md) |

Set **Value Store Key** to a clear name, such as `cookieValue`. That key holds the data for this Run so [**DoesQA Run**](/test-steps/express/doesqa-run.md) can pass it on.
{% endstep %}

{% step %}

## Start the child Flows

Add [**DoesQA Run**](/test-steps/express/doesqa-run.md) from **Express**.

1. Set a **Run Label**.
2. Choose **Flow Selection**: pick the child Flows, a [Run Recipe](/configuration/run-recipes.md), or tag filters.
3. In **Values**, map the stored key into the name the child expects:

```json
{
  "auth_token": "{{cookieValue}}"
}
```

`{{cookieValue}}` pulls the parent’s stored key. The child then reads `$auth_token` in its Set step.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
**Pro tip:** Use **Await & Match Results** on DoesQA Run when the parent should fail if a child Run fails. Use **Trigger Only** when the parent only needs to start the children.
{% endhint %}

{% hint style="warning" %}
A child Run cannot start another DoesQA Run. Keep session handoff to one parent level.
{% endhint %}

## Related

* [DoesQA Run](/test-steps/express/doesqa-run.md)
* [Store cookie](/test-steps/data/store-cookie.md)
* [Set cookie](/test-steps/data/set-cookie.md)
* [Reuse steps with Step Groups](/better-coverage/reuse-steps-with-step-groups.md)
* [Share data with Values](/better-coverage/share-data-with-values.md)
* [Run Recipes](/configuration/run-recipes.md)
