My understanding of sessionStorage is that it should be cleared when the session ends (browser/tab is closed, user navigates away, that kinda thing). Which is the desired behaviour.
However, in Chrome (the target browser) it isnt cleared on any of these events but seems to persist a la localStorage.
Any ideas why? I am wondering if its some weird setting in chrome where I sync from desktop to laptop or something?
Other than cookies, any way to solve this for a specific domain/application?
In case it changes anything
sessionStorage is accessed through a WebStorage
We are using ReactJS
latest version of Chrome available for Mac M1
Related
I have a functioning react application that I've been running in Chrome and Edge (mainly). I store various information in local storage. The application is working as expected, but for some reason, I've lost the ability to view the local storage variables in Edge (developer tools). They are there, because the application is working fine; I just can't see them. In Chrome I can see them fine. They were visible in Edge until I started my latest sprint. I unwound all the changes, but they are still not showing. I've tried clearing all the browser data, rebooting, etc.
Has anyone else encountered such an issue? I am just looking for some ideas of how to investigate the issue, because my current enquiries have not been successful.
Thanks in advance.
I'm developing a Flask app using flask-socketio, running it with socketio.run(app, debug=True), but every time I update any of the app's Javascript code and then refresh the browser, the changes do not take effect. If I update any of the Python code and then refresh, the Python changes do take effect - the only problem is with Javascript changes.
Clearing my browser's data resolves the issue, but I don't want to have to do that every time I make changes to my JS code. Is there another way?
Try ctrl-clicking (or shift-clicking) the refresh button.
What is likely happening is that the browser is "caching" your Javascript code. Clearing your browser's data clears the cache, and you get the newest updates...
In some browsers, you can avoid doing that by refreshing the page in a way that bypasses the cache. I think the shift-click trick works in Firefox, and ctrl-click is Chrome. Or, look up "bypass cache refresh [browser_name]".
If clearing cache does work, then another method (which I always use) is to keep your developer tools opened and make sure you've checked "Disable cache" in the network tab.
The "Disable cache" feature only works when developer tools is opened as I said.
I use Sentry to track the error in my website. The problem is sometimes chrome mobile for android has a null localStorage that cause all related method such as getItem or setItem will produce an error (Yeah, it's flaky). Have you ever got the problem like this before? I'd like to know the best solution for this problem.
Thanks :)
Maybe it is because this question is almost 2 years old and they've changed things but localStorage definitely works in Android Chrome with localStorage.setItem() and getItem() calls.
There is no need for the polyfill.
However, there is a problem / challenge that occurs if you've already put a page out there and you add localStorage that is related to Chrome Caching behavior. That's the problem I was having.
I had a page on the web than did some things via JavaScript. Then I added the simple localStorage calls to write and read a string value. I found that localStorage would fail.
Finally I loaded the .js file directly in my Android chrome browser and saw that the JS was the cached version of the file.
I reloaded the JS file and saw it update in Android Chrome so I went back to the page that uses the JS file and it still didn't save to localStorage.
To get it to work I had to close Android Chrome entirely (after refreshing the JS file) and finally localStorage did indeed work.
Here's a plunkr where you can point your mobile device at and save a value in localStorage to prove to yourself that it works.
http://plnkr.co/edit/dWgfh5WuMcM3InR0OaN4?p=info
Type in a screen name and press the Save button:
Then you can Stop and Run the plunkr again and you'll see that your Screen Name has been saved to localStorage and read out of localStorage to populate the top message:
I've actually tested this on various versions of Android, iOS (on an iPad) and in various desktop browsers and it works in every case.
Here's the code that calls localStorage.setItem()
function writeScreeNameToStorage(screenName){
var encodedScreenName = getEncodedValue(screenName);
localStorage.setItem("screenName", encodedScreenName);
}
This questions is related to this other one I posted a few days ago:
Instagram oAuth Authentication postMessage issue only with Mobile Browsers
Pretty much the issue I have is that when logging in my app with Instagram Chrome will behave inconsistently (on Android) and cause me some problems.
As I say in that other thread, IG authentication will reply with the required token and data to authenticate the user in my app.
It will do this by replying with a script that sends that data back to the original window, using window.opener.postMessage().
When I run my app on Chrome in Incognito mode, window.opener.postMessage will work without any issue since only one tab is opened and the reference to the opener isn't lost.
However, when I run this on the same browser but in regular mode (like probably 90% of people will) the behaviour is different.
Chrome will open a tab, close it and open a new one to input auth data. However, window.opener here won't work because the opener reference has been lost (is now null).
How come the same browser, on the same device will have such a different behaviour between two modes?
Does anybody know why this happens and how to prevent this from happening?
I am using localStorage in jQM and PhoneGap. If I don't delete localStorage manually, how long would it be stored? When it is deleted?
I would like to know how it works on mobile devices running Android and iOS. I found an opinion that iOS browser clears it occasionally, is that true?
The localstorage is persistent. It will be stored until you uninstall the application or clear it manually.