define(function(){
//write cookie
this.setCookie = function(key,value,expiredays,domain){
var exdate = new Date();
exdate.setDate(exdate.getDate() + expiredays);
document.cookie = key + “=” + escape(value) + “;expires=” + exdate.toGMTString() + “;path=/;domain=” + domain;
}
//read cookie
this.getCookie = function(key) {
if(document.cookie.length===0){
return '';
}
var _start = document.cookie.indexOf(key + "=");
if(_start != -1){
_start += key.length + 1;
_end = document.cookie.indexOf(";",_start);
if(_end===-1){
_end = document.cookie.length;
}
return unescape(document.cookie.substring(_start,_end))
}
}
//delete cookie
this.delCookie = function(key){
var value = getCookie(key),
exdate = new Date();
exdate.setDate(exdate.getTime() - 1);
if(value && value!=''){
document.cookie = key + '=' + escape(value) +';path=/;expires=' + exdate.toGMTString();
}
}
return this;
})