Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear localStorage on iOS Safari

How can you clear all localStorage on iOS Safari? Selecting 'Clear history and website data' does not remove localStorage (which seems odd, possibly a bug?).

A similar question was asked on apple.stackexchange.com but was closed.

I have recorded a video showing the issue in the iOS9.1 simulator.

like image 366
Alasdair McLeay Avatar asked Jan 15 '16 09:01

Alasdair McLeay


People also ask

How do I clear local storage in Safari?

Clear the local storage in Safari (Max OSX) To clear the local storage in Safari, do the following: From the Power BI service page, click the Develop menu and choose Web Inspector. On the Console tab, type localStorage. clear() in the field and press Enter.

Does iOS Safari have local storage?

Follow me on twitch! In short, you can't, but you can set a cookie via JavaScript 😉 Safari on iOS supports localStorage, but in Private Mode it simply throws an error when you try to save anything to it, which is not great. Also it breaks the behaviour of your app on iPhones and iPads.

What is localStorage in Safari?

The localStorage read-only property of the window interface allows you to access a Storage object for the Document 's origin; the stored data is saved across browser sessions.


1 Answers

So as you're seeing some browsers are more stubborn about keeping the local storage than others. One thing you can do is clear the storage using the localStorage API.

localStorage.clear() //clears everything in localStorage
localStorage.removeItem("test123") //removes only the specific property "test123"

I wrote an article on localStorage, that explains some of the nuances: http://www.richfinelli.com/local-storage-101/

I'm not sure how to clear it manually in iOS.

like image 128
Rich Finelli Avatar answered Sep 18 '22 13:09

Rich Finelli