The HTTP cookies is mainly used to send a small piece of data from a website and store it in a user's web browser. From this blog you will learn how to set the value in the cookies and getting the stored value from it using Jquery Plugin called js-cookie
js-cookie is a Jquery plugin which makes life easier to get and set the values for cookies.
Get the Js-cookie plugin from here.
Example
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title></title>
  5. <script src="https://code.jquery.com/jquery-3.1.0.min.js" ></script>
  6. <script src="Script/js.cookie.js"></script>
  7. <meta charset="utf-8" />
  8. </head>
  9. <body>
  10. <label id="lblcookie" style="font-family:Arial;font-style:italic;color:orange"></label>
  11. </body>
  12. </html>
  13. <script>
  14. $(document).ready(function()
  15. {
  16. Cookies.set('Message', 'Hello C-Sharp Corner')//set the cookie value
  17. var CookieValue=Cookies.get('Message')//get the value from cookie
  18. $("#lblcookie").text(CookieValue);
  19. })
  20. </script>
Set the Cookie
Cookie.set('[name/key of the cookie]','Value of the Cookie ')
Get the Cookie
Cookie.get('[name/key of the cookie]')
Output