JavaScript Read Cookie


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your 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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.