Ext.define("IceCap.state.session.Provider", {

	xtype: "icecap-state-session-provider",

	extend: "Ext.state.Provider",

	requires: [
		"Ext.state.Provider"
	],

	set: function(s_key, value) {

		var s_value = JSON.stringify(value);

		sessionStorage.setItem("icecap-" + s_key, s_value);
	},

	get: function (s_key, defaultValue) {

		var value =  sessionStorage.getItem("icecap-" + s_key);

		try {
			value = JSON.parse(value);
		}
		catch(err) {
			value = defaultValue;
		}

		return value;
	},

	clear: function(s_key) {

        sessionStorage.removeItem("icecap-"+ s_key);
	}
});
