In private mode, the user cannot use local storage, try the following:
var storageTestKey = 'sTest', storage = window.sessionStorage; try { storage.setItem(storageTestKey, 'test'); storage.removeItem(storageTestKey); } catch (e) { if (e.code === DOMException.QUOTA_EXCEEDED_ERR && storage.length === 0) { // private mode } else { throw e; } }
anton_byrna Oct 10 2018-12-12T00: 00Z
source share