PHPackages                             dmstr/yii2-cookie-button - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. dmstr/yii2-cookie-button

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

dmstr/yii2-cookie-button
========================

Widget to store 0/1 in a cookie for Yii2 Framework

1.0.1(2y ago)562.2k—0%12BSD-3-ClausePHP

Since Sep 4Pushed 7mo ago8 watchersCompare

[ Source](https://github.com/dmstr/yii2-cookie-button)[ Packagist](https://packagist.org/packages/dmstr/yii2-cookie-button)[ Docs](https://github.com/dmstr/yii2-cookie-button)[ RSS](/packages/dmstr-yii2-cookie-button/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (9)Used By (2)

Yii 2 Cookie Button
===================

[](#yii-2-cookie-button)

Yii 2 Cookie Button based on "Twitter Bootstrap" Button or ButtonGroup. Widget to store 0/1 in a cookie for Yii2 Framework.
Add and remove cookies via javascript, with help of [carhartl / jquery-cookie plugin](https://github.com/carhartl/jquery-cookie).

Usage
-----

[](#usage)

### Single button (default)

[](#single-button-default)

```
    $button = CookieButton::widget([
        'label' => FA::icon(FA::_EYE),
        'encodeLabel' => false,
        'toggleClass' => 'btn-primary',
        'cookieName' => 'Key-or-Name',
        'cookieValue' => 'on',
        'cookieOptions' => [
            'path' => '/',
            'http' => true,
            'expires' => strtotime('1 week')
        ],
        'options' => [
            'class' => 'btn-primary',
        ]
    ]);

```

### Switch button

[](#switch-button)

```
echo CookieButton::widget([
    'label' => ['On', 'Off'],           // String for default button, array for switch button
    'toggleClass' => 'btn-primary',     // Only needed if button type is switch
    'cookieName' => 'Key-or-Name',
    'cookieValue' => 'on',
    'options' => [
        'id' => 'cookieSwitchBtn',      // The button id
        'class' => 'btn-xs'             // Default button class
    ],
    'cookieOptions' => [
        'options' => [                  // 'options' are optional
            'expires' => 365,           // Define lifetime of the cookie.
                                        // Value can be a Number which will be interpreted as days
                                        // from time of creation or a Date object.
                                        // If omitted, the cookie becomes a session cookie.
            'path' => '/',              // Define the path where the cookie is valid.
                                        // By default the path of the cookie is the path of the page
                                        //where the cookie was created
                                        //(standard browser behavior).
            'domain' => 'example.com',  // Define the domain where the cookie is valid.
                                        // Default: domain of page where the cookie was created.
            'secure' => true            // If true, the cookie transmission requires a secure protocol (https).
                                        // Default: false.
        ]
    ]
]);

```

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Add repository url to the required section of your `composer.json` file.

```
"repositories": [
    {
        "type": "git",
        "url": "https://github.com/dmstr/yii2-cookie-button.git"
    }
],

```

Either run

```
php composer.phar require dmstr/yii2-cookie-button "*"

```

or add

```
"dmstr/yii2-cookie-button": "*"

```

to the required section of your `composer.json` file.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance45

Moderate activity, may be stable

Popularity34

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 64.3% 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.

###  Release Activity

Cadence

Every ~839 days

Total

5

Last Release

915d ago

Major Versions

0.2.0 → 1.0.02022-01-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b4ab2b6685ec71887908ec8cff261a16cd5bb24c69bb8ab52840e220f175f9d?d=identicon)[schmunk](/maintainers/schmunk)

---

Top Contributors

[![marc7000](https://avatars.githubusercontent.com/u/1118837?v=4)](https://github.com/marc7000 "marc7000 (9 commits)")[![schmunk42](https://avatars.githubusercontent.com/u/649031?v=4)](https://github.com/schmunk42 "schmunk42 (4 commits)")[![eluhr](https://avatars.githubusercontent.com/u/13000805?v=4)](https://github.com/eluhr "eluhr (1 commits)")

---

Tags

cmsyii2extension

### Embed Badge

![Health badge](/badges/dmstr-yii2-cookie-button/health.svg)

```
[![Health](https://phpackages.com/badges/dmstr-yii2-cookie-button/health.svg)](https://phpackages.com/packages/dmstr-yii2-cookie-button)
```

###  Alternatives

[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13825.6k47](/packages/skeeks-cms)[yiister/yii2-advanced-grid

Advanced GridView extension for Yii framework 2

4712.5k](/packages/yiister-yii2-advanced-grid)

PHPackages © 2026

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