One thing to note when using newer HTML5 api's is if it's supported by the browser the user is currently using. You can use a library like Modernizer to do feature detection.
The Aspnet Session and Local Storage are not equivalents. You can use Local Storage to maintain state if that is your goal.
In the past I have adopted a cookie based way of saving data instead of local storage (to safely target all browsers...with cookies on anyway). Maybe it can help. Please note the below code requires JSON2.
var Util = (function () {
return {
// Wrapper module for getting and setting cookies
CookieManager: {
set: function (name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
}
else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
},
get: function (name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
},
erase: function (name) {
this.set(name, "", -1);
}
}
}
})();
var UserPrefs = (function () {
var cookieName = 'UsrPrf';
var data = {};
return {
set: function (propName, value) {
if (data == null) data = {};
data[propName] = value;
},
get: function (propName, defaultValue) {
if (data == null) {
data = {};
return defaultValue;
} else {
return data[propName] == undefined ? defaultValue : data[propName];
}
},
load: function () {
try {
data = JSON.parse(Util.CookieManager.get(cookieName));
} catch (e) {
data = {};
}
return data;
},
save: function (ttl) {
if (!ttl) ttl = 30;
Util.CookieManager.set(cookieName, JSON.stringify(data), ttl);
}
};
})();