Skip to content

Instantly share code, notes, and snippets.

@lishoulong
Created February 16, 2016 04:17
Show Gist options
  • Save lishoulong/2a3c0da3fef215230bd9 to your computer and use it in GitHub Desktop.
Save lishoulong/2a3c0da3fef215230bd9 to your computer and use it in GitHub Desktop.
cookie not work!
<head>
<meta charset='utf-8'/>
<title>cookie</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<!--<script src="js/jquery.cookie.js" type="text/javascript"></script>-->
<script src="/path/to/js.cookie.js"></script>
<script type="text/javascript">
$(function(){
var COOKIE_NAME='username';
if( Cookies.get(COOKIE_NAME)) {
$("#username").val(Cookies.get(COOKIE_NAME));
}
$("#check").click(function(){
if(this.checked){
Cookies.set(COOKIE_NAME,$("#username").val(),{path:'/',expires:10});
}else{
Cookies.set(COOKIE_NAME,null,{path:'/'});
}
});
});
</script>
</head>
<body>
用户名:<input type="text" name="username" id="username" /> <br/>
<input type="checkbox" name="check" id="check" />记住用户名
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment