View Full Version : How to clear cookies when click on hyperlink (log out)

29 Nov 2011, 4:06 AM
Hi ,
I have a hyperlink When I click on hyperlink, I want to clear cookies and login page to be appeared
<a href="login.html" onclick="deleteCookie();">Logout</a></h2>

and I am calling function onclick of hyperlink as below :

function deleteCookie()

Please let me know how to do it.

29 Nov 2011, 5:02 AM
Ext.state.Manager has noting to do with cookies as such, unless you set Ext.state.CookieProvider as your state provider. The state provider is used to store your component states (like height, width, etc.) wherever you configure (cookies, etc).

If you want so set/unset cookies, you can use Ext.util.Cookies (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.util.Cookies)

29 Nov 2011, 5:48 AM
Before I post reply, I tried this way.

But my problem is I am calling hyperlink in viewport and creating above function. so when I click on hyperlink, i dont get anything
Can we call hyperlink and extjs stuff function on it ?

29 Nov 2011, 7:51 AM
If the cookie you're trying to clear is a session cookie then it should be cleared by the server, not the client. Clearing them on the client leaves you open to session hijacking as the cookies are still valid after the user has logged out. Session cookies should normally be HTTP-only to protect against XSS attacks, so you wouldn't be able to clear them in JS anyway.

If your cookies aren't being used to maintain sessions then I'd be interested to hear your use case as I'm currently struggling to imagine what other cookie-stored information you'd want to wipe when the user logs out.