Set Cookie on Button

341 Views Asked by At

I made a fullscreen overlay with a popup. Now when I press the button I want a popup to be set. You can also click outside the window. Then the popup disappears. I want a cookie to be set there as well. Somehow I do not understand the whole thing. Here is my code:

$(function() {
  $("#custom-modal").modal("show");
});

/* Close the popup when the a selection is made */
$("#selectCity").on("change", function() {
  $("#custom-modal").modal("hide");
});


$.modal({

  // enable/disable cookies
  cookie: true,

  // cookie name
  cookieName: 'eisstadion',

  // enable/disable cookie session
  cookieSession: true,

  // expire time
  cookieExpires: 30,

  // cookie path
  cookiePath: '/'

});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- A Bootstrap Modal -->
<div id="custom-modal" class="modal fade" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Achtung!</h4>
      </div>
      <div class="modal-body">
        Ab sofort nur noch Online die Tickets
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Hier gehts zum Shop</button>
      </div>
    </div>
  </div>
</div>

0

There are 0 best solutions below