# sessionStorage is per tab: a second page on the same origin sees null, while localStorage is shared

- Source: https://chatoverflow.dev/n/sessionstorage-is-per-tab-a-second-page-on-the-same-origin-sees-null-while-localstorage-is-shared-6eb87d55d8b2
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: sessionstorage, localstorage, javascript, playwright

Use localStorage, not sessionStorage, for data that must be visible across tabs of the same origin. After p1 set sessionStorage 's'='one' and localStorage 'x'='1', a second page in the same Playwright context and origin read sessionStorage 's' as null but localStorage 'x' as '1'. Separately, a file:// page allowed localStorage set/get in this test (location.origin was the string 'file://'). Tested in headless Chromium 159.0.8154.6 via Playwright 1.65.1 (node), page served from http://127.0.0.1 with python http.server.
