PHPackages                             pixxel/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. pixxel/cookie

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

pixxel/cookie
=============

PHP library for handling cookies.

2.0(3y ago)01911MITPHPPHP ^8.0

Since Dec 15Pushed 3y agoCompare

[ Source](https://github.com/pixxelfactory/cookie)[ Packagist](https://packagist.org/packages/pixxel/cookie)[ RSS](/packages/pixxel-cookie/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (4)Versions (10)Used By (1)

PHP Cookie library
==================

[](#php-cookie-library)

PHP library for handling cookies, based on the excellent library from Josantonius:

Basically it's a fork with modifications for PHP 8 upwards (union types ecc.), transforming the static methods to normal ones and real-time updates of the $\_COOKIE array.

---

- [Requirements](#requirements)
- [Installation](#installation)
- [Available Methods](#available-methods)
- [Quick Start](#quick-start)
- [Usage](#usage)
- [Tests](#tests)
- [TODO](#-todo)
- [Contribute](#contribute)
- [Repository](#repository)
- [License](#license)
- [Copyright](#copyright)

---

Requirements
------------

[](#requirements)

This library is supported by \*\*PHP versions 8.0 \*\* or higher.

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

[](#installation)

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

To install **PHP Cookie library**, simply:

$ composer require pixxel/cookie

The previous command will only install the necessary files, if you prefer to **download the entire source code** you can use:

$ composer require pixxel/cookie --prefer-source You can also **clone the complete repository** with Git:

$ git clone Or **install it manually**:

[Download Cookie.php](https://raw.githubusercontent.com/pixxelfactory/cookie/master/src/Cookie.php):

$ wget

Available Methods
-----------------

[](#available-methods)

Available methods in this library:

### - Set cookie:

[](#--set-cookie)

```
$cookie->set($key, $value, $time);
```

AttributeDescriptionTypeRequiredDefault$keyCookie name.stringYes$valueThe data to save.stringYes$timeExpiration time in days.stringNo365**\# Return** (boolean)

### - Get item from cookie:

[](#--get-item-from-cookie)

```
$cookie->get($key);
```

AttributeDescriptionTypeRequiredDefault$keyCookie name.stringNo''**\# Return** (mixed|false) → returns cookie value, cookies array or false

### - Extract item from cookie and delete cookie:

[](#--extract-item-from-cookie-and-delete-cookie)

```
$cookie->pull($key);
```

AttributeDescriptionTypeRequiredDefault$keyCookie name.stringYes**\# Return** (string|false) → item or false when key does not exists

### - Extract item from cookie and delete cookie:

[](#--extract-item-from-cookie-and-delete-cookie-1)

```
$cookie->destroy($key);
```

AttributeDescriptionTypeRequiredDefault$keyCookie name to destroy. Not set to delete all.stringNo''**\# Return** (boolean)

### - Set cookie prefix:

[](#--set-cookie-prefix)

```
$cookie->setPrefix($prefix);
```

AttributeDescriptionTypeRequiredDefault$prefixCookie prefix.stringYes**\# Return** (boolean)

### - Get cookie prefix:

[](#--get-cookie-prefix)

```
$cookie->getPrefix();
```

**\# Return** (string) → cookie prefix

Quick Start
-----------

[](#quick-start)

To use this class with **Composer**:

```
require __DIR__ . '/vendor/autoload.php';

use Pixxel\Cookie;
```

Or If you installed it **manually**, use it:

```
require_once __DIR__ . '/Cookie.php';

use Pixxel\Cookie;
```

Usage
-----

[](#usage)

Example of use for this library:

### - Set cookie:

[](#--set-cookie-1)

```
$cookie->set('cookie_name', 'value', 365);
```

### - Get cookie:

[](#--get-cookie)

```
$cookie->get('cookie_name');
```

### - Get all cookies:

[](#--get-all-cookies)

```
$cookie->get();
```

### - Pull cookie:

[](#--pull-cookie)

```
$cookie->pull('cookie_name');
```

### - Destroy one cookie:

[](#--destroy-one-cookie)

```
$cookie->destroy('cookie_name');
```

### - Destroy all cookies:

[](#--destroy-all-cookies)

```
$cookie->destroy();
```

### - Set cookie prefix:

[](#--set-cookie-prefix-1)

```
$cookie->setPrefix('prefix_');
```

### - Get cookie prefix:

[](#--get-cookie-prefix-1)

```
$cookie->getPrefix();
```

Tests
-----

[](#tests)

To run [tests](tests) you just need [composer](http://getcomposer.org/download/) and to execute the following:

$ git clone

$ cd PHP-Cookie

$ composer install Run unit tests with [PHPUnit](https://phpunit.de/):

$ composer phpunit Run [PSR2](http://www.php-fig.org/psr/psr-2/) code standard tests with [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer):

$ composer phpcs Run [PHP Mess Detector](https://phpmd.org/) tests to detect inconsistencies in code style:

$ composer phpmd Run all previous tests:

$ composer tests

☑ TODO
------

[](#-todo)

- Add new feature.
- Improve tests.
- Improve documentation.
- Refactor code for disabled code style rules. See [phpmd.xml](phpmd.xml) and [.php\_cs.dist](.php_cs.dist).

License
-------

[](#license)

This project is licensed under **MIT license**. See the [LICENSE](LICENSE) file for more info.

Copyright
---------

[](#copyright)

The original copyright: 2016 - 2018 Josantonius, [josantonius.com](https://josantonius.com/)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~254 days

Recently: every ~438 days

Total

9

Last Release

1409d ago

Major Versions

1.1.6 → 2.02022-07-08

PHP version history (4 changes)1.0.0PHP &gt;=7.0

1.1.0PHP &gt;=5.6

1.1.1PHP ^5.6 || ^7.0

2.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/dddd97de23d5d7def157effbc39845229ff52ade1bb6101b1b507e6507590191?d=identicon)[afpixxelfactory](/maintainers/afpixxelfactory)

---

Top Contributors

[![josantonius](https://avatars.githubusercontent.com/u/18104336?v=4)](https://github.com/josantonius "josantonius (41 commits)")

---

Tags

phphhvmcookies

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[josantonius/cookie

PHP library for handling cookies.

2238.7k4](/packages/josantonius-cookie)[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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