function ReadCookie(name) { var allCookie, CookieVal, length, start, end; CookieVal=""; name=name+"="; //acrescenta sinais de igual para evitar falsas coincidencias allCookie=document.cookie; length=allCookie.length; if(length>0) //nenhum Cookie - o usuario provavelmente os incinerou { start=allCookie.indexOf(name,0) if (start!=-1) { start+=name.length; end=allCookie.indexOf(";",start); if(end==-1) {end=length;} CookieVal=unescape(allCookie.substring(start,end)); } } return (CookieVal); } function WriteCookie(name,value,expires,domain,path,secure) { var CookieVal,CookieError; CookieVal=CookieError=""; if(name) { CookieVal=CookieVal+escape(name)+"=" if((value) || (value == "")) { CookieVal=CookieVal+escape(value); if(expires) { CookieVal=CookieVal+"; expires="+expires.toGMTString(); } if(domain) { CookieVal=CookieVal+"; domain="+domain; } if(path) { CookieVal=CookieVal+"; path="+path; } if(secure) { CookieVal=CookieVal+"; secure"; } } else { CookieError=CookieError+"Falha no valor"; } } else { CookieError=CookieError+"Falha no nome"; } if(!CookieError) { document.cookie=CookieVal; if(value!=ReadCookie(name)) { CookieError="Falha na escrita"; } } return CookieError; }