PHPackages                             c2is/cookie-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. c2is/cookie-bundle

ActiveSymfony-bundle[Templating &amp; Views](/categories/templating)

c2is/cookie-bundle
==================

Includes twig and css templating, js and php logic allowing the display of a cookie acceptance message

114.6k1PHP

Since Jun 14Pushed 9y ago4 watchersCompare

[ Source](https://github.com/c2is/C2iSCookieBundle)[ Packagist](https://packagist.org/packages/c2is/cookie-bundle)[ RSS](/packages/c2is-cookie-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

C2isCookieBundle
================

[](#c2iscookiebundle)

Bundles the resources and logic needed to display a cookie acceptance message on a website. The message disapears after the user closed it three times or explicitely clicked on "accept".

Includes a default twig + css template.

Install
-------

[](#install)

With composer:

```
$ composer require c2is/cookie-bundle ~1.0@dev

```

You will have to register the bundle into your AppKernel. The bundle depends on FOSJsRoutingBundle for the default javascript behaviour, so if you don't have it installed already, register that aswell:

```
// app/AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            ...
            new FOS\JsRoutingBundle\FOSJsRoutingBundle(), // If not already registered
            new C2is\Bundle\CookieBundle\C2isCookieBundle(),
        );
    }
}
```

Usage
-----

[](#usage)

You need to add the bundle routing configuration to your application routing like so:

```
# app/config/routing.yml
c2is_cookie:
    resource: "@C2isCookieBundle/Resources/config/routing.yml"

fos_js_routing:
    resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"
```

There are three routes used in this bundle. One serves the HTML template for your cookie acceptance panel, the others are called with Ajax requests to register the user actions.

To display the message, I recommend using an esi - the cache duration is managed by the plugin. This will allow the message to appear to a new user whatever your page cache configuration if you use HTTPCacheing. If you don't, it will fallback to the render Twig function and work aswell, so no worries. The default tempalte works best if placed just before or close to the body closing tag in your template.

```

    ...

        ...
        {{ render_esi(url('c2is_cookie_message')) }}

```

The default template comes with a default css you can include aswell:

```

        ...

    ...

```

For the whole thing to work properly you will need to include the javascript (you will need jquery aswell):

```

    ...

        ...

```

All this will be for naught before you install your assets though:

```
$ php app/console assets:install --symlink web

```

Configuration
=============

[](#configuration)

Bundle
------

[](#bundle)

The exhaustive default configuration is as follows:

```
c2is_cookie:
    cookie_name: 'c2is_cookie_accepted'
    cookie_expire: '+3 month' # The expire value for the cookies generated by this bundle. Can be an number or a strtotime valid string
    occurrences: 3 # The number of times the cookie panel has to be closed / accepted before it won't appear again
    actions:
        close: 1 # This number is incremented to the user current occurrences value when he closes the panel
        accept: 3 # This number is incremented to the user current occurrences value when he clicks "I accept"
```

Javascript
----------

[](#javascript)

The default twig template creates a div with an id of "cookiesLegalMessage". The JQuery plugin used by the bundle expects a container with that id to bind itself to.

If you override the Twig template and create your own panel, you can initialize the JQuery plugin like so:

```
$('#my-container').c2isCookie(
    on_closed: function(data) {
        ...
    },
    on_accepted: function(data) {
        ...
    }
);
```

Available configurations for that plugin is:

- on\_closed:

    defaults to false Can be a function that will be executed when the user closes the cookie acceptance panel. Will receive as argument a json array with the values success: true and message: 'a confirmation message'
- on\_accepted:

    defaults to false Can be a function that will be executed when the user accepts the cookie. Will receive as argument a json array with the values success: true and message: 'a confirmation message'

There also are events fired when the user closes or accepts the cookie panel:

- cookie\_closed
- cookie\_accepted

The default plugin behaviour on those actions is to hide the cookie panel. This is done before triggering the events, so you can display it back again in your event listener if you want to display a confirmation message or something. The events are fired from the container so you'll want to listen to that:

```
$('#my-container').c2isCookie();
$('#my-container').on('cookie_closed', function(data) {
    ...
});
```

Overriding
==========

[](#overriding)

You can override parts of this bundle to better fit your application needs

Template
--------

[](#template)

You can create a twig template of your own:

```
app/Resources/C2isCookieBundle/views/message.html.twig

```

Messages and translations
-------------------------

[](#messages-and-translations)

The exhaustive list of messages used and their default english value:

```
c2is.cookie.accept.message: 'By continuing to browse without changing your parameters, you accept the use of cookies or similar technologies to get services and offers tailored to your interests and to ensure secure transactions on our website.'
c2is.cookie.learn.more: 'Know more'
c2is.cookie.accept: 'OK'
c2is.cookie.close.message: 'By continuing to browse without changing your parameters, you accept the use of cookies or similar technologies on our website.'
c2is.cookie.accept.message: 'You accepted the use of cookies or similar technologies on our website.'
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9cf973b70f53fe114063efd8ca9e8c9dd45606ad49b5a9dba27fdecb0d0ada64?d=identicon)[gmanen](/maintainers/gmanen)

---

Top Contributors

[![gmanen](https://avatars.githubusercontent.com/u/1336033?v=4)](https://github.com/gmanen "gmanen (13 commits)")[![nikophil](https://avatars.githubusercontent.com/u/10139766?v=4)](https://github.com/nikophil "nikophil (2 commits)")

### Embed Badge

![Health badge](/badges/c2is-cookie-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/c2is-cookie-bundle/health.svg)](https://phpackages.com/packages/c2is-cookie-bundle)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)[symfony/ux-icons

Renders local and remote SVG icons in your Twig templates.

555.8M69](/packages/symfony-ux-icons)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
