PHPackages                             ellipse/cookie-encryption - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. ellipse/cookie-encryption

ActiveLibrary[HTTP &amp; Networking](/categories/http)

ellipse/cookie-encryption
=========================

Psr-15 middleware allowing to encrypt cookies using defuse/php-encryption

1.1.0(3y ago)424.6k↓33.3%[1 PRs](https://github.com/ellipsephp/cookie-encryption/pulls)MITPHPPHP &gt;=7.3

Since Nov 19Pushed 3y ago1 watchersCompare

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

READMEChangelogDependencies (8)Versions (5)Used By (0)

Cookie encryption
=================

[](#cookie-encryption)

This package provides a [Psr-15 middleware](https://www.php-fig.org/psr/psr-15/) allowing to encrypt cookies using [defuse/php-encryption](https://github.com/defuse/php-encryption).

**Require** php &gt;= 7.3

**Installation** `composer require ellipse/cookie-encryption`

**Run tests** `./vendor/bin/kahlan`

- [Getting started](#getting-started)

Getting started
===============

[](#getting-started)

This middleware takes an instance of `Defuse\Crypto\Key` from the [defuse/php-encryption](https://github.com/defuse/php-encryption) package and an array of bypassed cookie names as parameters. It will use defuse encryption mechanism to decrypt the cookies attached to the Psr-7 request and encrypt the cookies attached to the Psr-7 response. The cookies with a name in the bypassed array will stay untouched. When the decryption fails for one cookie, its value is set as an empty string.

```
