Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Cookie Consent Bundle Laravel Package

ekyna/cookie-consent-bundle

View on GitHub
Deep Wiki
Context7

CookieConsentBundle

Installation

composer require ekyna/cookie-consent-bundle

Register bundle and routes

// app/AppKernel.php
public function registerBundles()
{
    $bundles = [
        // ...
        new Ekyna\Bundle\CookieConsentBundle\EkynaCookieConsentBundle(),
    ];
    // ...
}
# app/config/routing.yml
ekyna_cookie_consent:
    resource: "@EkynaCookieConsentBundle/Resources/config/routing.yaml"

Use twig functions

{# base.html.twig #}
<!DOCTYPE html>
<html lang="en">
<head>
  <link href="{{ asset('bundles/ekynacookieconsent/css/cookie-consent.css') }}" rel="stylesheet" type="text/css" />
<head>
<body>
  {# ... #}
  
  {% block javascripts %}
    {# Renders the cookie consent widget (if not yet consented) #}
    {{ ekyna_cookie_consent_render() }}
    
    {# Check if cookie category has user consent ('analytic', 'marketing' or 'social_network') #}
    {% if ekyna_cookie_consent_category_allowed('analytic') %}
      <script src="https://example.org/analytic.js"></script>
    {% endif %}
  {% endblock javascripts %}
</body>
</html>

ekyna_cookie_consent_render() options with their default values:

{{ ekyna_cookie_consent_render({
    render_if_saved: false, // Whether to render even if consent has been saved.
    expanded: false,        // Whether to show settings
    dialog: true            // Whether to render as a dialog/popup
}) }}

Configuration

Available configuration with default values.

# app/config/config.yml
ekyna_cookie_consent:
    name: Cookie_Content   # The consent cookie name
    read_more_route: ~     # Route name to your privacy policy page
    position: centered     # Widget positioning ('centered' or 'bottom-right')
    categories:            # Cookies categories the user has to consent
        - analytic
        - marketing
        - social_network
    persist: true          # Whether to persist user consent

TODO

  • Encrypt cookie consent entity's IP property.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui