JSFiddle - React, Tailwind, and code Playground
by yiiBoy
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<button id="check-cookie">Check cookie</button>
JavaScript
$(function(){
$(document).on('click', '#check-cookie', function(e){
e.preventDefault();
if( $.cookie('yiiBoy') === null || $.cookie('yiiBoy') === undefined) {
var date = new Date();
var minutes = 0.25;
date.setTime(date.getTime() + (minutes * 60 * 1000));
$.cookie("yiiBoy", date, { expires: date });
alert("Cookie expired\n\nSet new cookie that expired at\n" + date);
}
else{
alert("You have actual cookie\n\n"+$.cookie('yiiBoy'));
}
});
});