Created
December 20, 2012 15:43
-
-
Save Swaagie/4346059 to your computer and use it in GitHub Desktop.
This will break user experience in IE8/9 badly, somehow storing a session cookie alongside large data sets in sessionStorage will block the UI on page reload/just before unload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create random value for key and value purposes, ignore the globals... | |
test = Math.round(Math.random()+1); | |
// Prepare data to be written | |
kilo = []; | |
lol = (function () {for(var i = 0; i < 100000; i++) { kilo.push({test: test}); }})(); | |
// Write to sessionstorage | |
sessionStorage.setItem('lol' + test, JSON.stringify(kilo)); | |
// Store some cookie | |
document.cookie = 'lol=yup writing; path=/; domain = .' + document.domain; | |
// The problem lies in the fact that the cookie is also written as session cookie... setting expires will fix it :D | |
dated = new Date; | |
dated.setMonth(dated.getMonth()+1); | |
document.cookie = 'lol=yup writing; expires=' + dated.toUTCString() + '; path=/; domain = .' + document.domain; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment