Answers for "laravel add to cookie"

PHP
3

setcookie in laravel 8

Cookie::queue(Cookie::make('name', 'value', $minutes));

Cookie::queue('name', 'value', $minutes);
Posted by: Guest on September-28-2020
0

Laravel Adding Cookie Consent

1 - Add this package 

https://github.com/spatie/laravel-cookie-consent

2 - publish the package to get the custom configuration

php artisan vendor:publish

3 - Add this in the home page in the top

@include('cookieConsent::index')

4 - Add the below style in the file “resources/views/vendor/cookieConsent/dialogContents.blade.php”

<div class="js-cookie-consent cookie-consent">
    <div class="alert alert-warning alert-dismissible fade show text-center" role="alert" style="margin-bottom: 0rem !important;">
        <span class="cookie-consent__message">
            {!! trans('cookieConsent::texts.message') !!}
        </span>

        <button class="js-cookie-consent-agree cookie-consent__agree btn btn-sm btn-primary">
            {{ trans('cookieConsent::texts.agree') }}
        </button>

        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
        </button>
    </div>
</div>
              
 Sources
- https://github.com/spatie/laravel-cookie-consent              
-  https://stackoverflow.com/questions/60719259/unable-to-locate-publishable-resources
Posted by: Guest on March-08-2022

Browse Popular Code Answers by Language