Posted By

jonkemp on 09/04/10


Tagged

javascript


Versions (?)

JavaScript Read Cookie


 / Published in: JavaScript
 

URL: http://www.quirksmode.org/js/cookies.html

  1. function readCookie(name) {
  2. var nameEQ = name + "=";
  3. var ca = document.cookie.split(';');
  4. for(var i=0;i < ca.length;i++) {
  5. var c = ca[i];
  6. while (c.charAt(0)==' ') c = c.substring(1,c.length);
  7. if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  8. }
  9. return null;
  10. }

Report this snippet  

You need to login to post a comment.