how to save thing in cookie js
function setCookie(name,value,days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
}
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
setCookie("user_email","[email protected]",30); //set "user_email" cookie, expires in 30 days
var userEmail=getCookie("user_email");//"[email protected]"
Also in JavaScript:
- javascript check type of variable var
- node js else
- js detect cmd+s
- nexusjs file upload
- jquery typeof undefined
- detect adblock javascript
- react native text input number only
- math random equitative js
- document delete element
- javascript ... operator
- nodejs foreach
- ionic 5 side menu example
- node js crud operation
- load_jsonl
- js array contains
- javascript get Time
- airbnb react native eslint
- js array get range
- how to move an element of an array in javascript
- string concat javascript
- switch/case with numeric range
- cloudwatch logs sdk.
- javascript appendchild image node
- check when keyup an input from a specific form jquery