Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine the existence of a key in a cookie ?

Status
Not open for further replies.

tangyi

Programmer
Sep 7, 2001
16
US
i'm trying to figure out how to determine the existence of a specfic key in a collection cookie.
anyone has any ideas on how to do this?
thanks.
 
Code:
function getCookie(name){
   var cname = name + "=";
   var dc = document.cookie;
   if(dc.length > 0){
      begin = dc.indexOf(cname);
      if(begin != -1){
         begin += cname.length;
         end = dc.indexOf(";", begin);
         if(end == -1) end = dc.length;
         return unescape(dc.substring(begin,end));
      }
   }
   return null;
}
From Heinle, Designing with Javascript: Creating Dynamic Web Pages.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top