Program:
Output:
<html> <head> <title>Cookies</title> <script> function create() { var cookies = document.getElementById("user").value; document.cookie="username = "+cookies+";"; alert("Cookie Created"+document.cookie); } function read() { var x ; if(document.cookie =="") { x=""; alert("Not Found"); } else { x=document.cookie; alert(" "+x); } } function del() { var d = new Date(); d.setTime(d.getTime()-(1000*60*60*24)) alert("Cookie Delete"); } </script> </head> <body> Enter Username :<input type="text" id="user"> <input type="button" onclick="create()" value="create"> <input type="button" onclick="read()" value="Reading"> <input type="button" onclick="del()" value="Delete"> </body> </html>
Output: