If you are in extjs application designing and coding, you might need to use use ‘Ext.util.Cookies.*’ function.
You can :
- Ext.util.Cookies.get(‘my_cookie’) : get cookie value
- Ext.util.Cookies.get(‘my_cookie’, ‘cookie_value’) : set cookie value
- Ext.util.Cookies.clear(‘my_cookie’) : clear cookie
In theory you can delete cookie by means of ‘clear’ function.
In practice, you should use :
Ext.util.Cookies.set('my_cookie', null, new Date("January 1, 1970")); Ext.util.Cookies.clear('my_cookie');
Because you can be faced to a problem where you cannot delete your cookie and cannot understand why…
Extjs : How to ‘real’ clear a cookie
made my day … because I "cannot delete the cookie and cannot understand why" 😉
in set cookie: it's Ext.util.Cookies.set('my_cookie', 'cookie_value')
I have a window for which I am using state (for position). there is a button in my interface which allows the user to reset the position of the window. however, if the window doesn’t exist, I want to delete the cookie for it so that when created, its shown at its original location. However, this doesnt seem to work. The cookies are deleted using your method but when the window is created, it somehow restores the state (and recreates the cookie). any suggestions?