If you write cookie from ASP.Net code behind and try to delete from JavaScript client side, you may notice that even when you set the expire day to past, it is not actually deleting the cookie. The reason being cookie string used in JavaScript to delete it must match EXACTLY with the cookie string sent by ASP.NET to save it.
ASP.Net sends cookie as
login=myloginvalue; expires=gmtdate; path=/
So if you have to delete it, You have to write the following JavaScript to delete the cookie:
var expires = new Date();
expires.setUTCFullYear(expires.getUTCFullYear() - 1);
document.cookie = 'login=; expires=' + expires.toUTCString() + '; path=/';
This works with both IE and Firefox. Thanks to Henri to post this solution :)
Wednesday, December 17, 2008
Monday, December 15, 2008
Unit test your JavaScript
JsUnit (http://www.jsunit.net/) is a great tool for unit testing your JavaScript code. Te best part is that it can be integrated with build process for continuos integration. This helps to identify the errors at a early stage of development rather than waiting till the code has reached QA.
QUnit (http://docs.jquery.com/QUnit) is another unit testing from jQuery stable. All jQuery libraries are tested using qUnit. I have not yet included this as part of build but as per their documentation it can be integrated into browser automation tools like Selenium or Mercury.
QUnit (http://docs.jquery.com/QUnit) is another unit testing from jQuery stable. All jQuery libraries are tested using qUnit. I have not yet included this as part of build but as per their documentation it can be integrated into browser automation tools like Selenium or Mercury.
Subscribe to:
Posts (Atom)