How to create a cookie?
How to create a cookie?
Rating:
The cookie is a property of the document object. It is used for sending and receiving data between the Web browser and a Web server.
Cookies can be created in JavaScript by using the following syntax:
[; expires=timeinGMTstring]
[; path=pathname]
[; domain=domainname]
[; secure]"
In the above syntax, cookiename is the name with which the cookie will be saved on the client computer.
The cookiedata is the data that is sent through the cookie.
The expires attribute is set to delete the cookie file after a certain date. The date should be converted to GMT string.
The path attribute is used to set the path of the directory from which the cookie is active.
The domain is used to search the domain to which the cookie is to be sent.
If the secure attribute is set, the cookies can only be accessible on the sites with secure connections.
Rating:
Other articles
- What is the do-while loop?
- How to use the charAt method?
- What is concatenation?
- What is the substring method?
- What are comments?
