Saturday, June 23, 2012

how to create cookies in javascript



how to set cookie in javascript
how to get cookie value in javascript


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>

function setCookie(){
document.cookie='mycookie';
 alert('cookies Successfully set');
}

function getCookie(){
 var cv = document.cookie.split( ';');
 alert(cv[0]);  // get cookies value
}

</script>

 <input type="button" value="setCookie" onclick="setCookie();"  name="setcookie" />

 <input type="button" name="getcookie" value="getcookie" onclick="getCookie();"  />

No comments:

Post a Comment

If you Satisfied , Please Leave a comment