--- title: "How to share login sessions between scenarios" slug: "share-login-session-between-scenarios" updated: 2026-01-26T06:09:22Z published: 2026-01-26T06:09:22Z canonical: "helpcenter.autify.com/share-login-session-between-scenarios" stale: true --- > ## Documentation Index > Fetch the complete documentation index at: https://helpcenter.autify.com/llms.txt > Use this file to discover all available pages before exploring further. # How to share login sessions between scenarios # Overview This page explains the procedure for performing a login operation in the first scenario of a test plan and carrying over the authentication information (cookie or token) to subsequent scenarios. By configuring this, you can execute tests while maintaining the login state across multiple scenarios. # Prerequisites To perform this procedure, confirm the cookie name and attribute information (Domain, Path, Secure, etc.) required to maintain the login state with your developer. # Steps ## 1. Create Workspace Variables Refer to [Creating Workspace Variables](/v1/docs/workspace-variables#creating-workspace-variables) and create a variable to save the authentication information. (e.g., `AUTH_TOKEN`) ## 2. Create a Login Scenario (Get Authentication Information) Create a scenario to be executed at the beginning of the test plan, obtain the authentication information, and save it to the workspace variable created in step 1. 1. Create a **New scenario** and record the login operation. 2. In the scenario editor, click **Insert step** and select **Playwright code step**. 3. Enter code that obtains the authentication information and returns the value, referring to the code below. ```javascript const cookies = await page.context().cookies(); // Check with the developer for the specific Cookie name const sessionCookie = cookies.find(c => c.name === 'COOKIE_NAME'); // Return the value to use in subsequent steps return sessionCookie ? sessionCookie.value : ''; ``` 4. Below the added step, click **Insert step** again and select **Override variable step**. 5. For **Variable to override**, select the workspace variable you created in step 1. 6. Select **Other step's output** as the input method for **Value**. 7. Select the previous "Playwright code step" as the reference. 8. Click **Save**. ## 3. Create Subsequent Scenarios (Use Authentication Information) Create subsequent scenarios that use the authentication information. 1. Create a new scenario. 2. Click **Insert step** as the first step of the scenario and add a **Playwright code step**. 3. Enter code that sets the cookie and accesses the page, referring to the code below. Note: Replace `{{AUTH_TOKEN}}` with the variable name created in Step 1. ```javascript await context.addCookies([  {    name: 'COOKIE_NAME',      // Actual Cookie name    value: '{{AUTH_TOKEN}}',  // Specify workspace variable name    domain: 'example.com',    // Target domain    path: '/',    httpOnly: true,           // Set according to actual attributes    secure: true,             // true for https    sameSite: 'Lax'           // Set according to actual attributes  } ]); // Specify the URL to access while logged in await page.goto('https://example.com/dashboard/target_page'); ``` ## 4. Configure the Test Plan Add the scenarios to a test plan and enable variable carry-over. 1. Open the **Test Plans** page and create a new test plan (or edit an existing one). 2. Add the "Login Scenario" created in Step 2 first. 3. Add the "Subsequent Scenarios" created in Step 3 in order. 4. In the test plan settings, check **Carry over overridden variable values to subsequent scenarios**. 5. Click **Save**. # Notes - **Dependency on the application**: This procedure depends on the authentication specifications of the application. If IP restrictions, token expiration, or Two-Factor Authentication (2FA) are configured, this method may not work. - **Constraints on execution order**: To ensure the variables are carried over, do not use parallel execution settings and fix the execution order of the scenarios.