Jquery Cookie Set, Delete Script

Jquery Cookie Script helps to handle cookies by set and delete options in your webpage.

Features

  • Useful script to create and clear cookies in few seconds.
  • Set a cookie by entering the Cookie Name and Value.
  • You can Create multiple cookies using this script.
  • Click delete button to clear the last created cookies.
  • Simple, responsive and supports all modern browsers.

Preview

Jquery Cookie Set, Delete


©h

Downloads


<!--Scripts by hscripts.com-->
<!--More scripts @ www.hscripts.com-->

<html>

<head>

<title>Jquery Cookie Set, Delete Script</title>
<script>

function createcookie(){var cook1 = $("#ck1").val();
var cook2 = $("#ck2").val();
if (cook1=='') {
alert("Enter Cookie name");}else if (cook2=='') {
alert("Enter Cookie value");}else{document.cookie = cook1+"="+cook2;;alert("Created Cookie:" +document.cookie);

$("#ck1").val('');

$("#ck2").val('');
}
}
function getCookie(){var cName = "";var cValue = "";var pCOOKIES = new Array();pCOOKIES = document.cookie.split('; ');for(bb = 0; bb < pCOOKIES.length; bb++){
NmeVal= new Array();NmeVal= pCOOKIES[bb].split('=');if(NmeVal[0]){cName = NmeVal[0];cValue = NmeVal[1];}}
deletecookie(cName,cValue);return cName;
}
function deletecookie(name,value) {
if (name!='') {if (confirm("Are you sure want to delete cookie:" +name+"="+value) == true) {var d = new Date();document.cookie = name+"="+value+";expires=" + d.toGMTString() + ";" + ";";
alert("Deleted Cookie:"+name+"="+value);
}
}else{alert("Cookie is not created");}
}
function loaded()
{var sds = document.getElementById("dum");if(sds == null){
alert("You are using a free package.\n You are not allowed to remove the tag.\n");}var sdss = document.getElementById("dumdiv");if(sdss == null){
alert("You are using a free package.\n You are not allowed to remove the tag.\n");
document.getElementById("content").style.visibility="hidden";
}
}
window.onload=loaded;

</script>

<style>

.frms
{
margin:0 auto;
font-family:Tahoma, Geneva, sans-serif;
color:#333;
font-size:.9em;
line-height:1.2em;
}
.frms input[type="text"]
{
width:25%;
background:#fff;
border:#ddd 1px solid;
border-radius:.35em;
-moz-border-radius:.35em;
-webkit-border-radius:.35em;
-o-border-radius:.35em;
padding:0 .5%;
margin-top:5px;
margin-bottom:15px;
height:35px;
}
.frms input:hover
{
box-shadow:#dae1e5 0px 0px 5px;
-moz-box-shadow:#dae1e5 0px 0px 5px;
-webkit-box-shadow:#dae1e5 0px 0px 5px;
-o-box-shadow:#dae1e5 0px 0px 5px;
}
.frms input:focus
{
-webkit-box-shadow: inset 7px 4px 7px -7px rgba(0,0,0,0.42);
-moz-box-shadow: inset 7px 4px 7px -7px rgba(0,0,0,0.42);
box-shadow: inset 7px 4px 7px -7px rgba(0,0,0,0.42);
border:#9d9983 1px solid;
}
.frms input[type="button"]
{
padding:7px 14px;
font-weight:bold;
color:#fff;
cursor:pointer;
border-radius:.3em;
-moz-border-radius:.2em;
-webkit-border-radius:.2em;
-o-border-radius:.2em;
margin:10px 0;
border:none;
}
input[type="button"]
{
background:#468cd2;
border-bottom:#3277bc 3px solid;
text-shadow:#214d73 1px 1px 0px;
}
@media screen and (max-width: 480px)
{
.frms input[type="text"]
{
width:35% !important;
}
}
</style>
</head>
<body>
<div class='frms' align='center' id='content'>
<center><b>Jquery Cookie Set, Delete</b></center>
<label>Enter Cookie Name :
</label><input type='text' id='ck1'><br>
<label>Enter Cookie Value :
</label><input type='text' id='ck2'><br>
<input type='button' value='Set Cookie' onclick='createcookie()'>
<input type='button' value='Delete Cookie' onclick='getCookie()'>
<div id="dumdiv" align="center" style=" font-size: 10px;color: #dadada;">
<a id="dum" href="https://www.hscripts.com" style="padding-right:0px; text-decoration:none;color: #dadada;text-align:center;">&copy;h</a>
</div>
</div>
</body>
</html>

<!--Scripts by hscripts.com-->
  • Release Date - 26-05-2015
  • Get free version without ©copyright link for just $10/-
  • For customization of this script or any script development, mail to support@hscripts.com

Usage

  • Copy and paste the above code into your HTML page and save it in .php extension.
  • To run the code, "jquery.js" file is necessary.
  • "createcookie()" function is used to create cookies by getting "name" and "value".
  • By passing the parameters "name" and "value" to the function "deletecookie()", the created cookie is deleted.

License

  • This Jquery code is given under GPL License
  • i.e. Free use for those who use the codes as it is.
  • Free, if your modification does not remove our copyright information and links.
  • Detailed License information can be found here.
  • You can purchase the script if your requirements does not meet our GPL License terms.

Related Scripts

Jquery Download


Ask Questions

Ask Question