简体   繁体   中英

LocalStorage in chrome Incognito Mode

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM