How to set and unset cookies using jQuery?
An HTTP cookie is a small piece of data sent from a server and stored on client-side by the browser itself, Cookies are made to keep track of user and also to provide one nice browsing experience. We can also set our on cookies in the browser according to our need.
Here we are using CDN of jQuery cookies to insert a cookie in the browser .
Note: Please keep your internet connection on while using this code as it uses CDN services for jQuery.
Example 1: Setting cookies in the browser after that we will remove that cookie.
Output: You can clearly see there is a cookie named GeeksforGeeks with a value. We can also set the cookie Expiry date.
- Before adding Cookie:
- After adding Cookies:
- After removing Cookie: