in JavaScript by
Q:
How to create a Cookie using JavaScript?

1 Answer

0 votes
by

The simplest way to create a cookie is to assign a string value to the document.cookie object, which looks like this −

Syntax −

document.cookie = "key1 = value1; key2 = value2; expires = date";

Here expires attribute is option. If you provide this attribute with a valid date or time then cookie will expire at the given date or time and after that cookies' value will not be accessible.

Click here to read more about JavaScript
Click here to read more about Insurance

Related questions

0 votes
asked Dec 3, 2019 in JavaScript by rajeshsharma
0 votes
asked Oct 19, 2019 in JavaScript by SakshiSharma
0 votes
asked Dec 3, 2019 in JavaScript by rajeshsharma
+1 vote
asked Dec 4, 2019 in JavaScript by SakshiSharma
0 votes
asked Nov 15, 2020 in JavaScript by rajeshsharma
...