JQuery的Cookie插件使用

<mce:script type="text/javascript" src="js/jquery-1.4.2.min.js" mce_src="js/jquery-1.4.2.min.js"></mce:script> <mce:script type="text/javascript" src="js/jquery_plugins/cookie.js" mce_src="js/jquery_plugins/cookie.js"></mce:script>

$(document).ready(function(){ //设置mycookie的值 $("#setcookie").click(function(){ //$.cookie("mycookie", null, '66', { path: '/', expires: 1 }); $.cookie("mycookie", null, { key1:'66', key2:'77' }, { path: '/', expires: 1 }); return false; }); //获取mycookie的值 $("#getcookie").click(function(){ //alert($.cookie("mycookie")); alert($.cookie("mycookie", "key1")); alert($.cookie("mycookie", "key2")); return false; }); //删除mycookie的值 $("#deletecookie").click(function(){ $.cookie("mycookie",null,null); return false; }); });

<a href="#" mce_href="#" id="setcookie">设置mycookie</a><br /> <a href="#" mce_href="#" id="getcookie">获取mycookie</a><br /> <a href="#" mce_href="#" id="deletecookie">删除mycookie</a><br /> <form runat="server"> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /> </form>

 

在服务器端创建一个Cookie:

//向客户端发送一Cookie protected void Button1_Click(object sender, EventArgs e) { HttpCookie ck = new HttpCookie("mycookie","66"); ck.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(ck); }

你可能感兴趣的:(jquery,server,function,null,Path,button)