LocalStorage in chrome Incognito Mode
Asked Answered
W

1

15

So In my Angular 1.5 application, I want to retain data on page load also,

So I am using $window.localStorage.

I am reading some value from localStorage and it also works fine in incognito mode.

The page refreshes and yet the values are retained.

if($window.localStorage.selectedServers !== undefined)
    selectedObj = JSON.parse($window.localStorage.selectedServers);

The problem is

When I copy the Url and open in a new tab incognito itself,

The localStorage gets undefined.

How to get rid of this issue? Or what am I doing wrong?

Widget answered 1/7, 2017 at 3:58 Comment(4)
incognito mode will only keep/store the values temporarily, other 'tabs' will not have access. Your history will disappear too. There is no workaround (that I know of)Loon
Check out developer.mozilla.org/en-US/docs/Web/API/Web_Storage_APILoon
Possible duplicate of Web Storage (sessionStorage and localStorage) in private browsing mode (incognito)Loon
I use LocalStorage to keep user ID. After each refresh the incognito takes the user id from the notmal window and keeps it (doesen't sync with the normal window). Is this espected?Hither
H
14

When I copy the Url and open in a new tab incognito itself,

The localStorage gets undefined.

This is because as mentioned in the comments, incognito / private browsing windows will not retain local / session storage. Therefore when you open a new tab they are empty.

Hyperbaton answered 19/10, 2020 at 23:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.