JavaScript can create, read, and delete cookies with the document.cookie property.
Syntax:
document.cookie = "key1 = value1; key2 = value2; expires = date";
Where:
expires: is an optional attribute that specifies the date of cookie expiration.
Example:
document.cookie = "username=jai;
Related topics:
- What is JavaScript?
- What are the advantages of JavaScript?
- What are the disadvantages of JavaScript?
- Is JavaScript a case-sensitive language?
- How to use external JavaScript file?
- How to create javascript object?
- How to add method to javascript object?
- What does the isNaN() function?
- What is the difference between undefined value and null value?
- How to access cookie using JavaScript?
- How to create cookie using JavaScript?
- How to read cookie using JavaScript?
- How to get cookie by name in JavaScript?
- How to delete cookie using JavaScript?
- How to redirect a url using JavaScript
- How to print a web page using JavaScript?
- How to handle exceptions in JavaScript?