In HTML5, is the localStorage object isolated per page/domain?

Nathan Moos picture Nathan Moos · Nov 17, 2010 · Viewed 70.2k times · Source

Is the HTML5 localStorage object isolated per page/domain? I am wondering because of how I would name localStorage keys. Do I need a separate prefix? Or can I name them whatever I want?

Answer

Nick Craver picture Nick Craver · Nov 17, 2010

It's per domain and port (the same segregation rules as the same origin policy), to make it per-page you'd have to use a key based on the location, or some other approach.

You don't need a prefix, use one if you need it though. Also, yes, you can name them whatever you want.