minor cookie code changes
This commit is contained in:
parent
de2ad5a02f
commit
9729cbeae5
|
@ -3,11 +3,11 @@
|
|||
<head>
|
||||
<title>check.wit.com</title>
|
||||
<style>
|
||||
body {
|
||||
width: 100em;
|
||||
margin: 0 auto;
|
||||
font-family: Tahoma, Verdana, Arial, sans-serif;
|
||||
}
|
||||
body {
|
||||
width: 100em;
|
||||
margin: 0 auto;
|
||||
font-family: Tahoma, Verdana, Arial, sans-serif;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -112,39 +112,33 @@ console.log("Your screen resolution = " +
|
|||
<br>
|
||||
|
||||
|
||||
<h2>All cookies</h2>
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
var theCookies = document.cookie.split(';');
|
||||
for (var n in theCookies) {
|
||||
document.write(theCookies[n] + "<BR>\n");
|
||||
}
|
||||
// Simple create & show all set cookies
|
||||
|
||||
function createCookie(name,value,days) {
|
||||
var expires = "";
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (days*24*60*60*1000));
|
||||
expires = "; expires=" + date.toUTCString();
|
||||
}
|
||||
document.cookie = name + "=" + value + expires + "; path=/";
|
||||
}
|
||||
|
||||
function readCookie(name) {
|
||||
var nameEQ = name + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for(var i=0;i < ca.length;i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function eraseCookie(name) {
|
||||
createCookie(name,"",-1);
|
||||
var expires = "";
|
||||
if (days != null) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (days*24*60*60*1000));
|
||||
expires = " expires=" + date.toUTCString();
|
||||
console.log("days=" + days + " expires=" + expires + "\n");
|
||||
}
|
||||
document.cookie = name + "=" + value + expires + " path=/;";
|
||||
console.log("createCookie doesn't work? " + name + "=" + value + expires + "; path=/");
|
||||
console.log("document.cookie currently set as: " + document.cookie + "\n");
|
||||
}
|
||||
|
||||
createCookie('check.wit.com','test',7);
|
||||
createCookie('check.wit.com 2','test2',2);
|
||||
createCookie('check.wit.com 3','test3',2);
|
||||
|
||||
// print out all the cookies
|
||||
document.write("<h2>All cookies</h2>\n");
|
||||
var theCookies = document.cookie.split(';');
|
||||
for (var n in theCookies) {
|
||||
document.write(theCookies[n] + "<BR>\n");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<h2>All objects in window.navigator</h2>
|
||||
|
|
Loading…
Reference in New Issue