set permanent cookie

master
Gustavo Luigi 2022-10-18 11:59:41 -03:00
parent 74ae8a67b5
commit f41c897085
2 changed files with 17 additions and 18 deletions

View File

@ -295,23 +295,6 @@
@include('template.'.config('settings.template').'.content.includes.footer')
@include('template.'.config('settings.template').'.content.includes.scripts')
<script src="https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js"></script>
<script>
$(window).on('load', function(){
if(Cookies.get('cookies-consent') == undefined){
$("#cookie-settings").animate({bottom: '0%'}, 1000);
$('.btn-cookies-consent').click(function(event){
event.preventDefault();
let cookiesConsent = $(this).attr('data-cookies');
if(cookiesConsent != undefined) Cookies.set('cookies-consent', cookiesConsent);
else{
if($('#functional-cookies').prop('checked') && $('#analytics-cookies').prop('checked') && $('#profile-cookies').prop('checked')) Cookies.set('cookies-consent', 1);
else Cookies.set('cookies-consent', 0);
}
$('#modal-cookie-settings').modal('hide');
$("#cookie-settings").animate({bottom: '-100%'}, 1000);
});
}
});
</script>
<script src="{{storage('js/cookies-consent.js')}}"></script>
</body>
</html>

16
js/cookies-consent.js Normal file
View File

@ -0,0 +1,16 @@
$(window).on('load', function () {
if (Cookies.get('cookies-consent') == undefined) {
$("#cookie-settings").animate({ bottom: '0%' }, 1000);
$('.btn-cookies-consent').click(function (event) {
event.preventDefault();
let cookiesConsent = $(this).attr('data-cookies');
if (cookiesConsent != undefined) Cookies.set('cookies-consent', cookiesConsent, { expires: 365 });
else {
if ($('#functional-cookies').prop('checked') && $('#analytics-cookies').prop('checked') && $('#profile-cookies').prop('checked')) Cookies.set('cookies-consent', 1, { expires: 365 });
else Cookies.set('cookies-consent', 0, { expires: 365 });
}
$('#modal-cookie-settings').modal('hide');
$("#cookie-settings").animate({ bottom: '-100%' }, 1000);
});
}
});