S
S
Sergey2015-03-27 10:22:55
JavaScript
Sergey, 2015-03-27 10:22:55

Cookie counter junk in Chrome, how to cure?

I'm learning php on the Specialist's video course. Now the lesson on cookies and I had a problem with them in the chrome browser.

$visitCounter = 0;
if(isset($_COOKIE['visitCounter'])){
$visitCounter = $_COOKIE['visitCounter'];
}
$visitCounter ++;

$lastVisit = '';
if(isset($_COOKIE['lastVisit']))
  $lastVisit = date('d-m-y H:i:s',$_COOKIE['lastVisit']);
setcookie('visitCounter', $visitCounter, 0x7FFFFFFF);
setcookie('lastVisit', time(), 0x7FFFFFFF);

Accordingly, visitCounter is displayed in the index (you have been so many times) and if in Mozilla and Opera the score is +1, then in Chrome +2 after each update. What could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
fomenko_alexandr, 2018-02-16
@fyapy

I think that the event should be hung not on the document, but on the input form itself
. should be something like this:
$('.text').on('input', function () {
clearInterval(timerPostAuthor);
});
Only in this case the execution of setInterval will stop. But, you can restart a new interval in the function of the same event

F
FanatPHP, 2015-03-27
@FanatPHP

in the wrong CNC implementation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question