Why is writing to the local storage impossible in private browsing mode?

We are developing a webbased lottery website. We use the local storage to store the lottery numbers selected by the user. This way we can assure, that the user doesn't loose the data entered if a page is reloaded or when he leaves the game and returns after a while.


This works fine in all browsers except Safari where we have a problem if the users use private browsing. In Safari it is not possible to write to the local storage in private browsing mode. All other browsers allow it and just clear the local storage whenever the session ist terminated.


What's the reason for this behaviour? Why doesn't safari behave like the other browsers?

Replies

hasStorage = -> try mod = new Date localStorage.setItem mod, mod.toString() result = localStorage.getItem(mod) == mod.toString() localStorage.removeItem mod return result