how to save thing in cookie js
JavaScript
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]"document.cookie = "username=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
document.cookie = "username=John Doe";
Also in JavaScript:
- Title
- client timezone offset in JavaScript
- Category
- JavaScript
- Title
- create an empty array js
- Category
- JavaScript
- Title
- get screen resolution jquery
- Category
- JavaScript
- Title
- how to flip a Number in javascript
- Category
- JavaScript
- Title
- how to count the rows of gridview in asp.net using jquery
- Category
- JavaScript
- Title
- How do you start a Node Application, if the entry file is index.js:
- Category
- JavaScript
- Title
- javascript check for null variables
- Category
- JavaScript
- Title
- javascript change element id
- Category
- JavaScript
- Title
- How do I get Month and Date of JavaScript in 2 digit format
- Category
- JavaScript
- Title
- how to change node version
- Category
- JavaScript
- Title
- javascript capitalize first letter
- Category
- JavaScript
- Title
- get current url react router
- Category
- JavaScript
- Title
- how to pass a value to a react funtion without immediately firing it
- Category
- JavaScript
- Title
- disable mixed content via javascript
- Category
- JavaScript
- Title
- filter keys from object using ramda
- Category
- JavaScript
- Title
- javascript array map stack
- Category
- JavaScript
- Title
- javascript array flatten
- Category
- JavaScript
- Title
- conditional jsx property
- Category
- JavaScript
- Title
- get looping in jquery
- Category
- JavaScript
- Title
- get random item from array javascript
- Category
- JavaScript
- Title
- find last element in array javascript
- Category
- JavaScript
- Title
- declarar una funcion javascript
- Category
- JavaScript
- Title
- how to compare a string with its ending in javascript
- Category
- JavaScript
- Title
- create child element in javascript
- Category
- JavaScript
- Title
- how to change tag name in js html
- Category
- JavaScript
- Title
- $pull mongoose
- Category
- JavaScript
- Title
- convert base64 to uint8array javascript
- Category
- JavaScript
- Title
- angular filter ngfor
- Category
- JavaScript
- Title
- how to position View absolute react native
- Category
- JavaScript
- Title
- cascading dropdown for forms react
- Category
- JavaScript
- Title
- bootstrap 4 form validator with jquery
- Category
- JavaScript
- Title
- is javascript good
- Category
- JavaScript
- Title
- does a function inside a function need to be called?
- Category
- JavaScript
- Title
- angular http client
- Category
- JavaScript
- Title
- discord.js login code
- Category
- JavaScript
- Title
- express render
- Category
- JavaScript
- Title
- clone aJavaScript object
- Category
- JavaScript
- Title
- how to get nth fibonacci javascript
- Category
- JavaScript
- Title
- angular sanitize vs validators
- Category
- JavaScript
- Title
- install nodejs from ubuntu 18.04
- Category
- JavaScript
- Title
- javascript check if date is today
- Category
- JavaScript
- Title
- calling function from function object javascript
- Category
- JavaScript
- Title
- javascript array push
- Category
- JavaScript
- Title
- angular subscribe
- Category
- JavaScript
- Title
- how to get last item in array javascript
- Category
- JavaScript
- Title
- append to array js
- Category
- JavaScript
- Title
- file input disable open file picker javascript
- Category
- JavaScript
- Title
- get all a tags javascript
- Category
- JavaScript
- Title
- boucle for of javascript
- Category
- JavaScript
- Title
- angular ng-click toggle class
- Category
- JavaScript
- Title
- brute force search javascript
- Category
- JavaScript
- Title
- delete with unlinksync node
- Category
- JavaScript
- Title
- covid
- Category
- JavaScript
- Title
- how to convert string to int a array in javascript
- Category
- JavaScript
- Title
- For-each over an array in JavaScript
- Category
- JavaScript
- Title
- foreach async typescript
- Category
- JavaScript
- Title
- how to make a vowel counter in javascript
- Category
- JavaScript
- Title
- add value to array javascript
- Category
- JavaScript
- Title
- insert item into array specific index javascript
- Category
- JavaScript
- Title
- faker js
- Category
- JavaScript
- Title
- how to freeze js object
- Category
- JavaScript
- Title
- algolia remove object
- Category
- JavaScript
- Title
- How to write on a web page javascript
- Category
- JavaScript
- Title
- fetch composition API in Vue3
- Category
- JavaScript
- Title
- how to add button in alert box in react native
- Category
- JavaScript
- Title
- how to validate the radio button using jquery
- Category
- JavaScript
- Title
- How do I check if an element is hidden in jQuery?
- Category
- JavaScript
- Title
- angularjs switch
- Category
- JavaScript
- Title
- how to store value in session using javascript in php
- Category
- JavaScript
- Title
- events in javascript
- Category
- JavaScript
- Title
- how to a property from a JavaScript object
- Category
- JavaScript
- Title
- apache log format json
- Category
- JavaScript
- Title
- (function (g, d, a) {})(window, document, jQuery);
- Category
- JavaScript
- Title
- create a json object in javascript
- Category
- JavaScript
- Title
- dotnet core ajax post of an ojject site:stackoverflow.com
- Category
- JavaScript
- Title
- how to make ajax request javascript
- Category
- JavaScript
- Title
- convert negative number to positive in javascript
- Category
- JavaScript
- Title
- Alert.alert closing expo
- Category
- JavaScript
- Title
- how to loop audio in js
- Category
- JavaScript
- Title
- get image file width javascript
- Category
- JavaScript
- Title
- how to delete a variable in js
- Category
- JavaScript
- Title
- how to access model data in jsp spring mvc
- Category
- JavaScript
- Title
- beforeeach jest
- Category
- JavaScript
- Title
- javascript array contains object
- Category
- JavaScript
- Title
- how to push items in array in javascript
- Category
- JavaScript
- Title
- javascript clear localstorage
- Category
- JavaScript
- Title
- javascript add to a dictionary
- Category
- JavaScript
- Title
- angular material toolbar with logo
- Category
- JavaScript
- Title
- inline style boarder radius jsx
- Category
- JavaScript
- Title
- chrome add bookmark that prefixes text
- Category
- JavaScript
- Title
- discord js get badge user
- Category
- JavaScript
- Title
- adding element to array javascript
- Category
- JavaScript
- Title
- disable yellow box react native
- Category
- JavaScript
- Title
- install php7 runtime brackets
- Category
- JavaScript
- Title
- how to inject service in component angular 6
- Category
- JavaScript
- Title
- http interceptor angular
- Category
- JavaScript
- Title
- if else practice javascript
- Category
- JavaScript
- Title
- export apk react native
- Category
- JavaScript
- Title
- javascript clone object
- Category
- JavaScript
- Title
- javascript click button by id
- Category
- JavaScript