3 ms·
Discord does this. Try to find the login cookie. When discord loads, it copies it out of localstorage into a js var and deletes the localstorage. So if you exa
by Thorrez 5y ago
Discord does this. Try to find the login cookie.
When discord loads, it copies it out of localstorage into a js var and deletes the localstorage. So if you examine localstorage it will be empty. On page unload it copies it back into localstorage. So if you want to see the value, you have to make sure no discord tabs are open in your browser.
I believe one reason for this is to prevent self-xss. It's hard for a malicious person to write a snippet of js to steal the login cookie now that it's no longer in localstorage. Another reason might be to prevent bots. It's hard for someone to automate a discord account if there's no way to get the account's login cookie.
- xg15 5y agoWouldn't this cause problems with multiple tabs/windows? Like, if I have one Discord tab open (so localstorage is cleared) and I open a second one in parallel, will I be logged out in the second one?
- Thorrez 5y agoI didn't look into it too deeply. Maybe if there are multiple windows they can communicate with each other in some way.
- brabel 5y ago"in some way" --> probably postMessage to send the variable to the new tab.
- toomanybeersies 5y agoService workers would be the solution to that problem, wouldn't they?