0

I've set my app to use state with this code:

Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

But now I'm having a problem. How to destroy all states cookies??

My app needs to destroy the states when user clicks logout button.

I've tried this, but it doesn't work:

Ext.state.Manager.clear();

How to solve this?? Thank you very much.

Fitrah M
  • 983
  • 3
  • 17
  • 31

3 Answers3

1

Like so

//create the CookieProvider and create the state manager;
var cp=new Ext.state.CookieProvider();
Ext.state.Manager.setProvider(cp);

//save some values in the state
Ext.state.Manager.set('a', 1)
Ext.state.Manager.set('b', [1,2,3]);

//show what's inside
console.log(cp, cp.state);

//Here it comes. This is how to clear all states
for (var item in cp.state) {
    Ext.state.Manager.clear(item);
}
Christiaan Westerbeek
  • 10,619
  • 13
  • 64
  • 89
0

This is an old question but - ExtJs 4 now has a clearAll() method.

Ext.state.Manager.clearAll();

Samwise
  • 65
  • 1
  • 1
  • 6
0

The docs say you need to pass in a name of the token to clear. Essentially you just need to clear the cookies, you can try clearing that specific cookie or try all of them that are accessible to your domain. You can either use Ext.util.Cookies or any of the generic javascript cookie handling routines out there.

see How can I delete all cookies with JavaScript?

Community
  • 1
  • 1
dbrin
  • 15,525
  • 4
  • 56
  • 83