Create, Read, and Delete Cookies in JavascriptHello Friends,

This post will explain you how you can create, read and delete the cookies in your webpage using Javascript.

Here is the code to create cookies,
In this below code, you can see, Cookies is Set to Name "RajeshCookie" and value is set to "Rajesh" and its expire time is set to next month as shown in below code.

//for creating a cookie

<script type="text/javascript">
<!--
   var today = new Date();
   var nextMonth = new Date(today.getYear(), today.getMonth()+1, today.getDate());
   setCookie("RajeshCookie", "Rajesh", nextMonth);
// -->
</script>

Here is the code to read cookies, //for reading the cookie
<script type="text/javascript">
<!--
      var szName = getCookie("RajeshCookie");
// -->
</script>

Here is the code to Delete cookies, //for deleting the cookie
<script type="text/javascript">
<!--
      deleteCookie('RajeshCookie');
// -->
</script>

Let me know, if you have any query..

Thanks Hope this post will help you, if yes please put comment below of this page,
Technical Team of Induway,
Induway Technologies,
Email: inquiry@induway.com
Induway Technologies (India)
www.induway.com

 

 

Disclaimer: This is a genuine effort by www.Induway.com, Induway Technologies is in no way responsible for the above mentioned information it is solely based upon the research work.

 

Leave a Reply

Your email address will not be published. Required fields are marked *