Javascript Code to Get Cookie Value by Name from Cookies

 JavaScript code to get cookie value by name from cookies:
  1. function getCookie( name ) 
  2. {      
  3.     var start = document.cookie.indexOf( name + "=" );  
  4.     var len = start + name.length + 1;  
  5.     if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) 
  6.     {  
  7.         return null;  
  8.     }  
  9.     if ( start == -1 ) return null;  
  10.     var end = document.cookie.indexOf( ';', len );  
  11.     if ( end == -1 ) end = document.cookie.length;  
  12.     return unescape( document.cookie.substring( len, end ) );  
  13. }