0

I'm writing a JavaScript game using HTML5 localStorage to save games between sessions. I want to warn the player if their browser is not currently set up to persist localStorage between sessions, for one reason or another. Two situations I can think of are private browsing or incognito mode, and if they have cookies disabled. There might be other reasons I haven't thought of. How can I know whether to pop up the warning?

I'm not worried about users explicitly clearing their localStorage, that's fine. I'm only concerned about users who are failing to actually save their games without realizing it.

Cosmologicon
  • 2,127
  • 1
  • 16
  • 18
  • In localStorage there is no expiration rules, that's all up to the browser and the users settings, so I don't think you'll be able to check how long the data is persisted, other than simply saving data and see if it's there at a later point, which defeats the point. – adeneo Dec 07 '13 at 17:46

1 Answers1

0

The documentation for incognito mode specifically says that websites won't behave differently. I believe this means that the answer is no.

It's an answer for similar question by DeadMG.

Community
  • 1
  • 1
Ginden
  • 5,149
  • 34
  • 68
  • Do you know where in the documentation it says that? The exact wording might be a hint as to the possibility of exceptions. – Cosmologicon Dec 07 '13 at 20:24
  • Chrome: open incognito mode, read description. Firefox: I don't know. – Ginden Dec 08 '13 at 13:58
  • Thanks, but I'm looking and [all I see is this](http://help.comodo.com/uploads/Comodo%20Dragon/cc05948e1bc19ef4d043c103f910787a/5eac818f1e1c4adc19d335055b06586b/6cbeefe3fd8f2cc91303d2948a4a998c/p&s_incognito%20mode.png), which doesn't say anything about websites behaving the same. The [learn more link](https://support.google.com/chrome/answer/95464?hl=en) also doesn't say anything like that. I'm on Ubuntu, so it might be different for you. Can you possibly quote the part you're seeing that says that? – Cosmologicon Dec 08 '13 at 16:47
  • "Going incognito doesn't affect the behavior of (...) software". – Ginden Dec 08 '13 at 17:12
  • I'm pretty sure that's a warning that software you interact with (eg servers) is under no obligation to respect the fact that you're in incognito mode. Obviously going incognito does affect the behavior of the browser, which is software, and is in fact the piece of software whose behavior I'm concerned with. – Cosmologicon Dec 08 '13 at 17:50
  • You can ask Google. ;) But any way to detect users in incognito mode is a privacy leak. `window` in Chrome has `incognito` property - but it's avaible **only** for Chrome Extensions, not for scripts. I think you shouldn't care about people browsing web in incognito mode - they know what they are doing. – Ginden Dec 08 '13 at 18:04
  • Really? You really think that pretty much all players are actively aware that their saved game will be erased when they close the window? Because that actually happened to one of my players and they (reasonably IMHO) thought it was a bug. – Cosmologicon Dec 09 '13 at 00:27