yii2-cookiemonster Yii extension to manage cookie warning

yii2-cookiemonster

  1. What is it for?
  2. Requirements
  3. Installation
  4. Usage
  5. Configuration
  6. `box` options
  7. `content` options
  8. `cookie` options
  9. `mode` possible values
  10. Default layouts
  11. GitHub repo
  12. Yii 1.1 version

Yii 2 extension to manage cookie warning

What is it for?

In 2009, the European Union sought new regulations as part of an "e-privacy" directive, seeing cookies as a potential threat to privacy, because users often don't know they are being tracked. This extension adds the information about cookies for the Yii website.

Requirements

Yii 2

Installation

Get it through composer by adding the package to your composer.json:

{
    "require": {
        "bizley/cookiemonster": "*"
    }
}

Or run `composer require bizley/cookiemonster`.

Usage

Add this code in your main template file just before `<?php $this->endBody() ?>`

<?= \bizley\cookiemonster\CookieMonster::widget() ?>

This will render widget with all default options (and 'top' layout). If you want to configure it add options array.

<?= \bizley\cookiemonster\CookieMonster::widget([/* options here */]) ?>

All options (and options' options) are described below. For example if you want to use custom message on the button and use 'bottom' layout set:

<?= \bizley\cookiemonster\CookieMonster::widget([
    'content' => array(
        'buttonMessage' => 'OK', // instead of default 'I understand'
    ),
    'mode' => 'bottom'
]); ?>

Configuration

You can set widget options by passing array to the widget() method with the following keys:

  • 
    
  • 
    
  • 
    
  • 
    
  • 
    

`box` options

  • 
    
  • 
    
  • 
    
  • 
    
  • 
    
  • 
    
  • 
    
  • 
    
  • 
    
  • 
    
  • 
    
  • 
    
  • 
    
  • 
    
  • 
    
  • 
    

`content` options

  • 
    
  • 
    
  • 
    
  • 
    
  • 
    
  • 
    

`cookie` options

  • 
    
  • 
    
  • 
    
  • 
    
  • 
    

`mode` possible values

  • 
    
  • 
    
  • 
    
  • 
    

Default layouts

bottom
<div style="display:none;z-index:10000;position:fixed;background-color:#fff;font-size:12px;color:#000;bottom:0;left:0;width:100%;box-shadow:0 -2px 2px #000" class="CookieMonsterBox">
    <div style="margin:10px" class="">
        We use cookies on our websites to help us offer you the best online experience. By continuing to use our website, you are agreeing to our use of cookies. Alternatively, you can manage them in your browser settings.<button style="margin-left:10px" class="CookieMonsterOk" type="button">I understand</button>
    </div>
</div>
box
<div style="display:none;z-index:10000;position:fixed;background-color:#fff;font-size:12px;color:#000;bottom:20px;right:20px;width:300px;box-shadow:-2px 2px 2px #000;border-radius:10px" class="CookieMonsterBox">
    <div style="margin:10px" class="">
        We use cookies on our websites to help us offer you the best online experience. By continuing to use our website, you are agreeing to our use of cookies. Alternatively, you can manage them in your browser settings.<button style="margin-left:10px" class="CookieMonsterOk" type="button">I understand</button>
    </div>
</div>
top
<div style="display:none;z-index:10000;position:fixed;background-color:#fff;font-size:12px;color:#000;top:0;left:0;width:100%;box-shadow:0 2px 2px #000" class="CookieMonsterBox">
    <div style="margin:10px" class="">
        We use cookies on our websites to help us offer you the best online experience. By continuing to use our website, you are agreeing to our use of cookies. Alternatively, you can manage them in your browser settings.<button style="margin-left:10px" class="CookieMonsterOk" type="button">I understand</button>
    </div>
</div>

GitHub repo

https://github.com/bizley/yii2-cookiemonster

Yii 1.1 version

https://github.com/bizley/Yii-CookieMonster

0 0
3 followers
0 downloads
Yii Version: 2.0
License: BSD-2-Clause
Category: User Interface
Developed by: Bizley
Created on: May 29, 2015
Last updated: 2 years ago

Related Extensions