/////////////////////////////////////////////////////////////////// // Cookie handling routines. // // Author: Vidar Kongsli 1999 / 2001 // /////////////////////////////////////////////////////////////////// // Return true is the cookie with name given by 'unid' exists function checkCookie( unid ) { if (document.cookie.indexOf( unid ) == -1 ) { return true; } // return true; // var cookie = getCookie( unid ); // alert(cookie); // if ( cookie=="") { // return true; // } return window.confirm( "A certain user is allowed to submit this form only once. It seems that you have submitted this form earlier. Do you want to try to submit anyway?" ) ; } function cookieExists( unid ) { if (document.cookie.indexOf( unid ) == -1 ) { return false; } else { return true; } } //function: setCookieExp //scope: local but general //purpose: stores a cookie //param: nam - name of the cookie //param: val - value of the cookie //param: day - expiration time in days function setCookieExp(nam,val,day) { var exp=new Date(); exp.setTime(exp.getTime()+day*86400000); document.cookie=nam+'='+escape(val)+'; expires='+exp.toGMTString(); } //function: setCookie //purpose: setCookieExp with default expiration in 14 days //see: setCookieExp() function setCookie(nam,val) { setCookieExp(nam,val,14); } //function: getCookie //scope: local but general //purpose: retrieves the value of the named cookie //param: nam - name of the cookie //return: value of the cookie or empty string if cookie is not set function getCookie(nam) { var allCook=document.cookie; new RegExp(name + "=([^;]*)").exec( allCook ); return unescape( RegExp.$1 ); }