Blogger9:- Add cookie in your blog to track last visit Time. 0

| | ,

Hello friends this tricks very useful for blogger blog owner to track last visit time for  your blog visitor

Follow simple step to add this special widget in your blogger blog-------->>>>>>>>


* First go to your blogger Dashboard .

* Now click in design tab.

* Your are now here---->>> Add new element.

* Click in Add new gadget which is sidebar.

* When open new window select HTML/Javascript from list.

* When open new blank box copy below code and paste in blank box.


<script type = "text/javascript">
 
var days = 730; // days until cookie expires = 2 years.
var lastvisit=new Object();
var firstvisitmsg="This is your first visit to this page. Welcome!";
lastvisit.subsequentvisitmsg="Welcome back visitor! Your last visit was on <b>[displaydate]</b>";
 
lastvisit.getCookie=function(Name){
var re=new RegExp(Name+"=[^;]+", "i");
if (document.cookie.match(re))
return document.cookie.match(re)[0].split("=")[1];
return'';
}
 
lastvisit.setCookie=function(name, value, days){
var expireDate = new Date();
 
var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days));
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}
 
lastvisit.showmessage = function() {
var wh = new Date();
if (lastvisit.getCookie("visitc") == "") {
lastvisit.setCookie("visitc", wh, days);
document.write(firstvisitmsg);
}
 
else {
var lv = lastvisit.getCookie("visitc");
var lvp = Date.parse(lv);
var now = new Date();
now.setTime(lvp);
var day = new Array("Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat");
var month = new Array ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
var dd = now.getDate();
var dy = now.getDay();
dy = day[dy];
var mn = now.getMonth();
mn = month[mn];
yy = now.getFullYear();
var hh = now.getHours();
var ampm = "AM";
if (hh >= 12) {ampm = "PM"}
if (hh >12){hh = hh - 12};
if (hh == 0) {hh = 12}
if (hh < 10) {hh = "0" + hh};
var mins = now.getMinutes();
if (mins < 10) {mins = "0"+ mins}
var secs = now.getSeconds();
if (secs < 10) {secs = "0" + secs}
var dispDate = dy + ", " + mn + " " + dd + ", " + yy + " " + hh + ":" + mins + ":" + secs + " " + ampm
document.write(lastvisit.subsequentvisitmsg.replace("[displaydate]", dispDate))
}
 
lastvisit.setCookie("visitc", wh, days);
 
}
 
lastvisit.showmessage();
 
</script>


* Now save your HTML/Javascript and you are Done my friends comment this .

StumpleUpon DiggIt! Del.icio.us Blinklist Yahoo Furl Technorati Simpy Spurl Reddit Google I'm reading: Blogger9:- Add cookie in your blog to track last visit Time. ~ Twitter FaceBook

0 Responses So Far:

Categories

Select Your Categories