| Below code will help us to get and set the value of cookies in javascript
< html>
< head>
< script type = "text/javascript">
function GetCookieVal()
{
if( document.form.btnname.value == "" )
{
alert("Enter some value!");
return;
}
cookieval= escape(document.form.btnname.value) + ";";
document.cookie="name=" + cookieval;
document.write ("Setting Cookies : " + "name=" + cookieval );
}
script>
head>
< body>
< form name="myform" action="">
Enter name: < input type="text" name="btnname"/>
< input type="button" value="Get Cookie" onclick="GetCookieVal();" / >
< /form>
< /body>
< /html>
| | |