I need help with my script I can't seem to get it working. Can someone please help? I need a cookie script that stores the date and time of your last visit.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Last Visit</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="js_styles.css" type="text/css" />
</head>
<body >
<script type="text/javascript">
/* <![CDATA[ */
if (document.cookie) {
var cookieString = decodeURIComponent(document.cookie);
var cookieArray = cookieString.split("; ");
var lasVisit =
cookieArray[0].substring(cookieArray[0].indexOf("=")
+ 1, cookieArray[0].length);
document.write("<p>Your last visit was " + lastVisit
+ "</p>");
}
else
document.write("<p>This is your first visit.</p>");
var now = new Date();
var day = now.getDay();
var date = now.getDate();
var year = now.getFullYear();
var month = now.getMonth(0);
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
var days = new Array();
days[0] = "Sunday"; days[1] = "Monday"; days[2] = "Tuesday";
days[3] = "Wednesday"; days[4] = "Thursday"; days[5] = "Friday"; days[6] = "Saturday";
var thisVisit = days[day] + " " + month + "/" + date + "/" + year + " at "+ hours + ":" + minutes + ":" + seconds;
document.cookie = encodeURIComponent(thisVisit);
/* ]]> */
</script>
</body>
</html>


Reply With Quote


Bookmarks