javascript中Cookie的用法
16lz
2021-01-22
<html>
<head>
<title>l.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript">
function moveNext(object, index) {
}
</script>
</head>
<body>
<script type="text/javascript">
var today = new Date();
var expireDay = new Date();
var msperMonth = 24 * 60 * 60 * 1000 * 31;
//相当于一个月能不用登录的时间
expireDay.setTime(today.getTime() + msperMonth);
document.cookie = "name=zhang;expires=" +expireDay.toGMTString();
document.writeln("cookie已经写到硬盘上了");
document.writeln("内容是:" + document.cookie);
document.writeln("有效日期是:");
document.writeln(expireDay.toGMTString());
</script>
</body>
</html>
<head>
<title>l.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript">
function moveNext(object, index) {
}
</script>
</head>
<body>
<script type="text/javascript">
var today = new Date();
var expireDay = new Date();
var msperMonth = 24 * 60 * 60 * 1000 * 31;
//相当于一个月能不用登录的时间
expireDay.setTime(today.getTime() + msperMonth);
document.cookie = "name=zhang;expires=" +expireDay.toGMTString();
document.writeln("cookie已经写到硬盘上了");
document.writeln("内容是:" + document.cookie);
document.writeln("有效日期是:");
document.writeln(expireDay.toGMTString());
</script>
</body>
</html>
更多相关文章
- 你可以在android webview中自动链接日期吗?
- 函数的作用是:在javascript中将时间戳转换为人工日期
- 从服务器(任何服务器)获取当前日期和时间。仅限javascript
- 输入类型=日期的日期显示为dd-mm-yyyy格式
- 我可以使用onBlur事件对TextBox进行日期检查吗?
- Day.js :一个轻量的处理时间和日期的 JavaScript 库
- 使用Isotop过滤日期
- 如何使用Require JS配置具有第三方js依赖项的日期选择器?
- 第三节(JavaScript 对象、日期,函数)