Skip to content
This bundle adds privacy cookie banner into Symfony applications
Branch: master
Clone or download
Latest commit 7bde006 Jun 28, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
Banner Add possibility send other params in override template (#19) Mar 10, 2017
Factory Add possibility configure path cookie (#18) Mar 2, 2017
Resources Fixed JS syntax errors on cookiePath May 28, 2018
Twig EZP-25386: Librarie dependency problem on PrivacyCookieBundle Mar 24, 2016
.gitignore Removed user specific files from .gitignore file Nov 7, 2016
.php_cs Updated PHP CS fixer (#23) Jul 19, 2017
EzSystemsPrivacyCookieBundle.php EZP-25386: Librarie dependency problem on PrivacyCookieBundle Mar 24, 2016
LICENSE Updated (C)opyright year Feb 27, 2017 Update Jun 28, 2018
composer.json Remove Assetic - Update composer.json and (#21) Jul 21, 2017

Privacy Cookie Bundle


This bundle adds privacy cookie banner into Symfony applications.



  • Symfony v2.6 or later (including Symfony 3.x)


This package is available via Composer, so the instructions below are similar to how you install any other open source Symfony Bundle.

Run the following command in a terminal, from your Symfony installation root (pick most recent release):

php composer.phar require ezsystems/privacy-cookie-bundle

Enable the bundle in app/AppKernel.php file:

$bundles = array(
    // existing bundles
    new EzSystems\PrivacyCookieBundle\EzSystemsPrivacyCookieBundle(),

Add external assets to your bundle:

  • CSS:
  • JS:

Assetic (Optional)

Enable the Assetic bundle in app/AppKernel.php file:

$bundles = array( // ... // starting from Symfony 2.8 you have to enable AsseticBundle manually if you haven't done it before new Symfony\Bundle\AsseticBundle\AsseticBundle() );

Add the following minimal configuration in config.yml file to enable Assetic support in your application (Symfony 2.8 and later):

    debug: '%kernel.debug%'
    use_controller: '%kernel.debug%'
        cssrewrite: ~

If you are installing the bundle via composer require you must also copy assets to your project's web directory. You can do this by calling Symfony's built-in command from the project root directory:

For Symfony 2.x:

php app/console assets:install --symlink

For Symfony 3.x:

php bin/console assets:install --symlink

In production environment you have to dump assets using Assetic built-in command:

For Symfony 2.x:

php app/console assetic:dump -e=prod

For Symfony 3.x:

php bin/console assetic:dump -e=prod


Insert the following {{ show_privacy_cookie_banner(%privacy_policy_url%) }} helper somewhere in your footer template before the body ending tag. Replace the %privacy_policy_url% parameter with your policy page address.

Note that the %privacy_policy_url% parameter is not required, in this case no policy link will be shown.

The following optional parameters can be set as a second argument in an array format:

Parameter Default value Description
cookieName privacyCookieAccepted Sets your own status cookie name
cookieValidity 365 Says how many days privacy banner should be hidden when user accepts policy?
cookiePath null Specifies the cookie path (by default cookie will be available only for the current domain)
caption Cookies help us create a good experience (...) Sets your own banner message caption
learnMoreText Learn More Sets title and text of privacy link
extraParams Extra Params Send extra params in your override template

Example of usage in standard Symfony application:

{{ show_privacy_cookie_banner('') }}


{{ show_privacy_cookie_banner('', {
   cookieName: 'myCookie',
   cookieValidity: 7,
   cookiePath: '/',
   caption: 'Nice to see you here',
   learnMoreText: 'Find out more'
}) }}

If you are using eZ Publish / Platform you can use ez_urlalias to generate path for specified content object:

{{ show_privacy_cookie_banner(path('ez_urlalias', {contentId: 94}), {
   cookieName: 'myCookie',
   cookieValidity: 7,
   caption: 'Nice to see you here'
}) }}

Example of usage extraParams:

{{ show_privacy_cookie_banner('', {
   cookieName: 'myCookie',
   extraParams: {
       my_param1: value_my_param1 ,
       my_param2: value_my_param2
}) }}
You can’t perform that action at this time.