Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to set/get cookie in JavaScript

<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/3.0.1/js.cookie.min.js"></script>
Cookies.set('cookie_name', 'cookie_value', { expires: 365 });
Cookies.get('cookie_name'); // => 'value'
Cookies.remove('cookie_name');
Comment

js write and get cookie

// how to add to cookie
document.cookie = "yourKey=your value"
Comment

get cookie in javascript

function getCookie(cookie, name) {
  const q = {}
  cookie?.replace(/s/g, '')
    .split(';')
    .map(i=>i.split('='))
    .forEach(([key, value]) => {
      q[key] = value
    })
  return q[name]??null;
}
Comment

set cookie and get cookie in javascript

<script type="text/javascript">
    function setCookie(key, value, expiry) {
        var expires = new Date();
        expires.setTime(expires.getTime() + (expiry * 24 * 60 * 60 * 1000));
        document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
    }

    function getCookie(key) {
        var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
        return keyValue ? keyValue[2] : null;
    }

    function eraseCookie(key) {
        var keyValue = getCookie(key);
        setCookie(key, keyValue, '-1');
    }

</script>
Comment

how to create a cookie in javascript

document.cookie = "firstName=Anthony"; 
Comment

document cookies javascript

cookieData=document.cookie.split("; ");

for(let i=0; i<cookieData.length; i++){

  cookieData[i]=cookieData[i].split("=");
  cookieName=cookieData[i][0];
  cookieValue=cookieData[i][1];

  //write your cookie name which you want to see in the place of 'mobNo'
  if(cookieName==='mobNo'){
    console.log(cookieData[i]);
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: delete multiple keys from object javascript 
Javascript :: how to make proptypes either or 
Javascript :: fullcalendar v5 time format am/pm 
Javascript :: import typography react 
Javascript :: subtract dates javascript 
Javascript :: delete all node_modules folders recursively windows 
Javascript :: js get object keys 
Javascript :: how many days old am i 
Javascript :: datatables add row 
Javascript :: javascript get point of line intersection 
Javascript :: how to use secondary color in material ui useStyle 
Javascript :: jquery set att 
Javascript :: how to get enum item name in javascript 
Javascript :: replace element from string javascript 
Javascript :: regex match line that does not contain string 
Javascript :: get status of a user discord js 
Javascript :: async await useeffect react 
Javascript :: invisible character javascript 
Javascript :: generate random number between two numbers javascript 
Javascript :: javascript sort array by object property 
Javascript :: TypeError: this.authenticate is not a function 
Javascript :: golang parse jason 
Javascript :: angular show time ago 
Javascript :: reload page angular one time 
Javascript :: how to find all permutations of an array with javascript 
Javascript :: multiple line string in jquery 
Javascript :: json foreach in javascript 
Javascript :: javascript create element with class 
Javascript :: how to append the dropdown values by jquery each function 
Javascript :: jquery get body 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =