PHPackages                             oui/oui\_cookie - 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. oui/oui\_cookie

ActiveTextpattern-plugin[Utility &amp; Helpers](/categories/utility)

oui/oui\_cookie
===============

Cookie management plugin for Textpattern CMS

1.0.0-beta4(7y ago)483[2 issues](https://github.com/NicolasGraph/oui_cookie/issues)GPL-2.0-onlyPHP

Since May 28Pushed 6y ago2 watchersCompare

[ Source](https://github.com/NicolasGraph/oui_cookie)[ Packagist](https://packagist.org/packages/oui/oui_cookie)[ Docs](https://github.com/NicolasGraph/oui_cookie)[ RSS](/packages/oui-oui-cookie/feed)WikiDiscussions dev Synced today

READMEChangelog (6)Dependencies (2)Versions (5)Used By (0)

oui\_cookie
===========

[](#oui_cookie)

Introduction
------------

[](#introduction)

Set, check, read, reset or delete cookies manually or through GET/POST parameters.

. According to the [EU legislation](http://ec.europa.eu/ipg/basics/legal/cookies/index_en.htm#section_2), some cookies need the user consent before to be set.

### Plugin requirements

[](#plugin-requirements)

oui\_cookie’s minimum requirements:

- [Textpattern CMS](http://textpattern.com/) 4.6+.

Plugin management
-----------------

[](#plugin-management)

### Installation

[](#installation)

#### From the admin interface

[](#from-the-admin-interface)

1. [Download](https://github.com/NicolasGraph/oui_cookie/releases) the compiled plugin file or the source to compile a customized file.
2. Paste the content of the compiled plugin file under the “Admin &gt; Plugins”:?event=plugin tab and click the *Upload* button.
3. Confirm the plugin install by clicking the *Install* button on the plugin preview page.
4. Enable the plugin.

#### Via Composer

[](#via-composer)

After [installing Composer](https://getcomposer.org/doc/00-intro.md…)

1. Target your project directory:
    `$ cd /path/to/your/textpattern/installation/dir`
2. If it’s not already done, lock your version of Txp:
    `$ composer require textpattern/lock:4.6.2`, where `4.6.2` is the Txp version in use.
3. Install oui\_cookie:
    `$ composer require oui/oui_cookie`

### Update

[](#update)

#### From the admin interface

[](#from-the-admin-interface-1)

1. Follow the installation instruction above.

#### Via Composer

[](#via-composer-1)

```
$ composer update oui/oui_cookie
```

### Uninstall

[](#uninstall)

#### From the admin interface

[](#from-the-admin-interface-2)

1. Check the box on the left of the plugin row under the “Admin &gt; Plugins”:?event=plugin.
2. open the select list at the bottom of the plugins table and choose *Delete*.
3. confirm the plugin deletion.

#### Via Composer

[](#via-composer-2)

```
$ composer remove oui/oui_cookie
```

Tags
----

[](#tags)

### oui\_cookie

[](#oui_cookie-1)

```

```

or

```

    […]

```

#### Attributes

[](#attributes)

##### Required

[](#required)

 `name` **Value:** string; none by default.
The cookie (and GET/POST parmater) name you want to use. If no other attibutes are defined, the tag will read and display the related value.

##### Manually set a cookie

[](#manually-set-a-cookie)

 `value` **Value:** string; none by default.
A value to manually set the named cookie.
You can also set the cookie value by using a continer tag like you would for a variable.

##### Set a cookie through a GET/POST parameter

[](#set-a-cookie-through-a-getpost-parameter)

 `values` **Value:** comma separated list of strings; none by default.
A comma separated list of accepted values for the GET/POST parameter and its cookie.

 `default` **Value:** string; none by default.
A default value.
If set, the plugin conditional tag will always be true if not check against a defined value.

 `delete` **Value:** string; none by default.
An GET/POST parameter value used to delete the cookie.

##### Optional cookie settings

[](#optional-cookie-settings)

 `duration` **Value:** [strtotime](http://php.net/manual/fr/function.strtotime.php) value, `+1 day` by default.
The duration of the cookie.

##### Delete a cookie

[](#delete-a-cookie)

 `delete` **Value:** `0` or `1`; `0` by default.
If set to `1` this attribute will delete the named cookie.

### oui\_if\_cookie

[](#oui_if_cookie)

```

    […]

    […]

```

This tag checks the status or the value of the cookie (and/or the related GET/POST parameter) defined by the `name` attribute.

#### Attributes

[](#attributes-1)

##### Required

[](#required-1)

 **`name`** **Value:** string; none by default.
The cookie (and GET/POST parameter) name you want to use.

##### Optional

[](#optional)

 `value` **Value:** string; none by default.
A value to check against the cookie (and/or the GET/POST parameter) value.

Examples
--------

[](#examples)

### Front-end articles sorting

[](#front-end-articles-sorting)

List the sort options you want to use:

```

        Size
        Weight

```

Then, catch the GET/POST parameter sent by this list to store it (useful to keep the sort order pages after pages).

```

```

Now use the new value as the value of the `sort` attribute of your article tag.

```

```

### Last viewed article

[](#last-viewed-article)

Store the current article id in a cookie:

```

```

Now, use the following code anywhere you want to display the last viewed article.

```

```

### EU cookies Warning

[](#eu-cookies-warning)

```

```

```

        This website uses cookies. I agree, remove this message!

```

Now, you can add some progressive enhancement to avoid to refresh the page if javascript is on.
However, note that it wouldn’t instantaneously display a potential alternative content placed before the `` tag if the cookie is not set/setting.

```

    (function() {
        // Get the link which should remove the warning.
        var accept = document.getElementById('accept_cookies');
```

```
        // If it exists, listen it…
        if (accept) {
            accept.addEventListener('click', removeWarning);
        }
```

```
        // It is clicked!
        function removeWarning(e){
            document.cookie = 'accept_cookies=yes;path=/;expires=864e2'; // Set the cookie for the whole domain for 1 day.
            var warning = document.getElementById('cookies-warning'); // Get the warning message to remove.
            warning.remove(); // Remove the message.
            e.preventDefault(); // Do not follow the link; everything's already done!
        };
    }());

```

Credits
-------

[](#credits)

### Author

[](#author)

[Nicolas Morand](https://twitter.com/NicolasGraph)
*Thank you to the Textpattern community and the core team.*

### License

[](#license)

This plugin is distributed under [GPL v2.0](https://www.gnu.org/licenses/gpl-2.0.txt).

oui\_cookie version 1.0.0-BETA3, Copyright © 2018 Nicolas Morand
This Textpattern plugin comes with ABSOLUTELY [NO WARRANTY](https://www.gnu.org/licenses/gpl-2.0.html#section11).
This is free software, and you are welcome to redistribute it [under certain conditions](https://www.gnu.org/licenses/gpl-2.0.html#SEC3).

### Changelog

[](#changelog)

- **1.0.0-beta3** (2018-07-06)
    - Changed: OOP related code rework;
    - Removed: Txp 4.5 support;
    - Adds [Composer](https://getcomposer.org/) support for [textpattern/installer](https://packagist.org/packages/textpattern/installer).
- **0.2.3** (2016-06-21)
    - Code rewrite;
    - manual cookie setting added;
    - `display` attribute removed (setting and reading are now separated);
    - deletion process changed.
- **0.1.3** (2016-05-29)
    - improves conditional tag results;
    - `delete` attribute unset by default (but any none valid value for a defined GET/POST parameter will delete the related cookie).
- **0.1.2** (2016-05-26)

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

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 ~258 days

Total

3

Last Release

2803d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/181702?v=4)[oui](/maintainers/oui)[@oui](https://github.com/oui)

---

Tags

cookiecookiestextpatterntextpattern-pluginplugincookietextpattern

### Embed Badge

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

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

PHPackages © 2026

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