Getting a Cookie in Javascript


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



Copy this code and paste it in your HTML
  1. function getCookie(name) {
  2. var cookies = document.cookie.split(/[; ]+/);
  3. for (var i = 0 ; i < cookies.length; i++) {
  4. if (cookies[i].substring(0,cookies[i].indexOf('=')) == name) {
  5. return cookies[i];
  6. }
  7. }
  8. }

URL: http://www.arachna.com/edu/tutorials/mini/cookies/javascript.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.