Episode 17 game · Chitragupta · Water
Chitragupta’s Three Chests
Kai turns dark mode off, reloads, and the dark comes back. Feel the Greedy Tsuzura turn every value into a string and share it with every tab, put each value in the chest that fits who reads it and how long it lives, then prove nothing comes back twisted or stolen.
Theme saved with localStorage.setItem('dark', dark)
Every value you store is written down as text. Watch the quotes.
1 · Feel the twist
Kai’s shop saves dark mode with localStorage.setItem('dark', dark), and the checkout step in localStorage too. Turn dark mode off, reload, then open a second order in another tab.
2 · Pick the right chest
For each value, choose how it is written and where it lives: who needs to read it, and how long should it last?
3 · The chest audit
Same shop, your choices: dark mode off and a reload, a settings object saved and read back, a second tab, and an injected script looking for the login.
New seal earned
The Tsuzura has nothing left to twist
Acharya’s Rule #17Pick the chest by who reads it and how long it lives. Keep secrets where JavaScript can’t reach.
setItem('dark', false) stores "false", which is truthy. Write with JSON.stringify, read with JSON.parse.
localStorage is shared by every tab and stays; sessionStorage belongs to one tab and ends when it closes.
Let the server set the session in an HttpOnly; Secure; SameSite=Lax cookie. Scripts can’t read it.