Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function createCookie(name,value,days) {
- if (days) {
- var date = new Date();
- date.setTime(date.getTime()+(days*24*60*60*1000));
- var expires = "; expires="+date.toGMTString();
- }
- else var expires = "";
- 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 oldCount = parseInt(readCookie('hitCount')) | 0;
- createCookie('hitCount', oldCount + 1, 7);
- var x = "5"; // x = "5" (string)
- x += 1; // x = "51" (string!)
- x += 5; // x = "515" (string!)
- ++x; // x = 516 (number)
- var cookieName = "increment";
- if ($.cookie(cookieName) == null){
- $.cookie(cookieName, 1, { expires: 10 });
- }else{
- var newValue = Number($.cookie(cookieName)) + 1;
- $.cookie(cookieName, newValue, { expires: 10 });
- }
Add Comment
Please, Sign In to add comment