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