M
M
midarovrk2015-11-16 18:31:16
JavaScript
midarovrk, 2015-11-16 18:31:16

Displaying information 15 times a day on cookies?

Hello.
Please help me modify the script:

<script type="text/javascript">
function setCookie(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 getCookie(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)
{
setCookie(name, "", -1);
}

function Cookie(name, days)

{if (!getCookie(name))

{setCookie(name, true, days); document.write('СОДЕРЖИМОЕ');}
}

Cookie('pokazrazvsutki', 1);
</script>

This script shows "CONTENT" 1 time per day for one visitor. Works on cookies.
Is it possible to somehow make the content shown not 1 time, but 15 times a day?
Apparently initially I didn’t explain correctly, I’ll add:
Ie . I need the CONTENT to be shown 15 times in a row (i.e. with each page refresh), and already 16 times the content was not shown, and it lasted exactly a day, or at 0:00 at night the cookie was overwritten and then all over again. Is this possible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
De YURII, 2015-11-16
@midarovrk

4th line in the code.
Change to
And paste it like
this. Thus, cookies will be created 15 times per day, since every 1.6 hours they will expire.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question