Inspecting localStorage and sessionStorage
You'll learn how to view, edit, and delete browser storage entries using DevTools, understanding their key-value structure and how they're scoped to specific domains.
What Are localStorage and sessionStorage?
Both localStorage and sessionStorage are browser APIs that store data as key-value pairs directly in the user's browser. Think of them like filing cabinets in your browser—localStorage keeps papers permanently (until manually cleared), while sessionStorage shreds everything when you close the tab.
Viewing Storage in DevTools
Open Chrome DevTools and navigate to the Application panel. In the left sidebar, expand either "Local Storage" or "Session Storage" to see a list of domains. Click any domain to view its stored key-value pairs in a table format.
Each row shows:
- Key: The identifier (always a string)
- Value: The stored data (also always a string, even if it looks like JSON)
Domain Scoping
Storage is scoped to the domain and protocol. Data stored on https://example.com is completely separate from https://different.com or even http://example.com. This security boundary prevents websites from accessing each other's data.
Editing and Deleting Entries
To edit a value, double-click it in the DevTools table, type your changes, and press Enter. The change takes effect immediately.
To delete an entry, right-click the row and select "Delete" or select it and press Delete/Backspace. You can also click "Clear All" (🚫 icon) to wipe all storage for that domain.
Why This Matters
Inspecting storage helps you debug issues with saved preferences, tokens, or cached data. You might discover why a user stays logged in (token in localStorage) or why settings reset after closing a tab (sessionStorage was used instead).
Key Takeaway: Browser DevTools let you inspect, modify, and delete localStorage and sessionStorage entries in real-time, revealing the key-value data structure and domain-specific scoping that controls what each site can access.