Create Cookie in Website using JavaScript

By Santhosh N

This explains how to create Cookie using JavaScript for the Website.

Syntax:
document.cookie = "name=value; expires=dateOfExpiry; path=pathToSave; domain=domain; secure";

Ex:
document.cookie = 'mycookie=testCookie;expires=Sun, 09 Jan 2011 10:00:00 IST';

Related FAQs

This is a way to check if the given string is in numeric format or not
This is how trimming of a string can be done in javascript is simpler manner.
Get the random number within the specified range
Create Cookie in Website using JavaScript  (666 Views)