Want more features on Pastebin? Sign Up, it's FREE!
Guest

getCookie function

By: a guest on Dec 15th, 2011  |  syntax: JavaScript  |  size: 0.22 KB  |  views: 163  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function getCookie(cookieName) {
  2.         var cookiePattern = new RegExp('(^|;)[ ]*' + cookieName + '=([^;]*)'),
  3.                 cookieMatch = cookiePattern.exec(document.cookie);
  4.                 if(cookieMatch){
  5.                         return cookieMatch[2];
  6.                 }
  7.                 return 0;
  8. };
clone this paste RAW Paste Data