home *** CD-ROM | disk | FTP | other *** search
- //----------------------------
- // This js file contains basic tools for cookie manipulation
-
- function SetCookie(sName,sVal,sExpires,sDomain,sPath,bSecure) {
- //-------------------------------------
- // Set a cookie.
- document.cookie = ( sName + "=" + escape(sVal) +
- ( (sExpires) ? "; expires=" + sExpires : "" ) +
- ( (sDomain) ? "; domain=" + sDomain : "" ) +
- ( (sPath) ? "; path=" + sPath : "" ) +
- ( (bSecure) ? "; secure" : "" ) );
- }
-
- function GetCookie(sName){
- //-------------------------------------
- // Traverse the cookie, looking for the passed cookie name.
- // If found, return the value, else return null.
- var sDelimName = ( sName + "=" );
- var iNameLength = sDelimName.length;
- var iCookieLength= document.cookie.length;
- var iNameStart = 0;
- while (iNameStart < iCookieLength){
- var iNameEnd = (iNameStart + iNameLength);
- if (document.cookie.substring(iNameStart, iNameEnd) == sDelimName){
- // If name found, get the associated value
- // (from iNameEnd to next ; or end of cookie)
- var iValueEnd = document.cookie.indexOf (";", iNameEnd);
- if (iValueEnd == -1){ iValueEnd = document.cookie.length }
- return unescape(document.cookie.substring(iNameEnd, iValueEnd));
- }
- iNameStart = ( document.cookie.indexOf(" ", iNameStart) + 1 );
- if (iNameStart == 0) break;
- }
- return null;
- }
-