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

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

phpsoftbox/cookie
=================

Cookie component for the PhpSoftBox framework

0125↓90.2%PHP

Since Mar 5Pushed 4mo agoCompare

[ Source](https://github.com/phpsoftbox/cookie)[ Packagist](https://packagist.org/packages/phpsoftbox/cookie)[ RSS](/packages/phpsoftbox-cookie/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Cookie
======

[](#cookie)

Компонент для работы с Cookie и Set-Cookie.

Пример
------

[](#пример)

```
use PhpSoftBox\Cookie\CookieJar;
use PhpSoftBox\Cookie\SetCookie;

$cookies = CookieJar::fromHeader('a=1; b=2');

$setCookie = SetCookie::create('sid', 'token')
    ->withHttpOnly(true)
    ->withSecure(true);

$headers = CookieJar::toHeaders([$setCookie]);
```

Middleware
----------

[](#middleware)

```
use PhpSoftBox\Cookie\CookieMiddleware;
use PhpSoftBox\Cookie\CookieQueue;
use PhpSoftBox\Cookie\SetCookie;

$queue = new CookieQueue();
$middleware = new CookieMiddleware($queue);

$queue->queue(SetCookie::create('token', 'abc'));
```

### Шифрование cookie

[](#шифрование-cookie)

Можно включить шифрование значений cookie через `phpsoftbox/encryptor`. Для исключений (например, сессионная cookie или `XSRF-TOKEN`) передайте список `except`.

```
use PhpSoftBox\Cookie\CookieMiddleware;
use PhpSoftBox\Cookie\CookieQueue;
use PhpSoftBox\Encryptor\Encryptor;

$encryptor = new Encryptor(defaultKey: $_ENV['APP_KEY'] ?? null);

$middleware = new CookieMiddleware(
    queue: new CookieQueue(),
    encryptor: $encryptor,
    except: ['XSRF-TOKEN', 'psb_session'],
);
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance52

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0279d150240c97d210034878b0467462246dc14d29b5618157ff6a8be49a50e3?d=identicon)[inspector-who](/maintainers/inspector-who)

---

Top Contributors

[![inspector-who](https://avatars.githubusercontent.com/u/6973963?v=4)](https://github.com/inspector-who "inspector-who (1 commits)")

### Embed Badge

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

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

###  Alternatives

[christian-riesen/base32

Base32 encoder/decoder according to RFC 4648

13333.9M74](/packages/christian-riesen-base32)[ticketswap/phpstan-error-formatter

A minimalistic error formatter for PHPStan

87718.9k56](/packages/ticketswap-phpstan-error-formatter)

PHPackages © 2026

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