Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js parse cookie string

const parseCookie = str =>
  str
    .split(';')
    .map(v => v.split('='))
    .reduce((acc, v) => {
      acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim());
      return acc;
    }, {});
Source by www.30secondsofcode.org #
 
PREVIOUS NEXT
Tagged: #js #parse #cookie #string
ADD COMMENT
Topic
Name
4+7 =