PDA

View Full Version : How to clear SessionStorage



treike
2 Sep 2011, 5:17 AM
Hello everyone,

I have the following problem. I am saving a loggedIn boolean value into the sessionStorage, but on Logout I want to clear the sessionStorage.
I have tried to use store.removeAll() and a store.sync()/store.save(), at first it is cleared, but on reload of the page, the sessionStorage is filled again.

How do I really clear the store?

This is the model I am using:


Ext.regModel('Usersession',{
fields: [
{name: 'id', type: 'int'},
{name: "loggedIn", type: "boolean"},

]
});


Ox.stores.usersession = new Ext.data.Store({
model: 'Usersession',
proxy: {

type: 'sessionstorage',
id : 'session'
},
autoLoad: false
});





And then in the logout method:


usersession.removeAll();
usersession.sync();


When I look into the console directly after calling these methods, usersession.data.length is 0, but after I reloaded the page it is 1 again.

treike
2 Sep 2011, 10:46 AM
Another way I have tried:

usersession.data.clear();

But as soon as I call load() on the usersession again I get back the old record. Why???

MPeg
3 Sep 2011, 12:27 AM
Hi, you need to empty proxy's data.
Look at this tip: http://t.co/3otXzwW