JSFiddle - React, Tailwind, and code Playground

HTML

<script src="//cdn.jsdelivr.net/jquery.cookie/1.3.1/jquery.cookie.js"></script>
<div id="counter"></div>

CSS

div {
  font-size: 48px;
  display: inline-block
}

JavaScript

//var delayCount = 24 * 60 * 60 * 1000;
var delayCount = 500; /* for test */

function setCounter(count) {
  $('#counter').text(19 - count);
}

var countPlaces = parseInt(($.cookie('mytimeout') || 0), 10);

setCounter(countPlaces);

var intervalCount = setInterval(function() {
  countPlaces++;
  setCounter(countPlaces);
}, delayCount);

var stopCount = setTimeout(function() {
  $('#counter').text('Увы мест больше нет').css('color', '#f00');
  clearInterval(intervalCount);
}, 9500);

window.onbeforeunload = function() {
  $.cookie('mytimeout', countPlaces, {
    expires: 7,
    path: '/'
  });
};