PHPackages                             selective/samesite-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. [Security](/categories/security)
4. /
5. selective/samesite-cookie

ActiveLibrary[Security](/categories/security)

selective/samesite-cookie
=========================

Secure your site with SameSite cookies

1.0.0(2mo ago)10144.0k—0%3MITPHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Sep 16Pushed 10mo ago1 watchersCompare

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

READMEChangelog (7)Dependencies (18)Versions (9)Used By (0)

selective/samesite-cookie
=========================

[](#selectivesamesite-cookie)

A PSR-15 middleware to secure your site with SameSite cookies 🍪

[![Latest Version on Packagist](https://camo.githubusercontent.com/972cdb2c52068898f778df5f50917cf50ace9a0f395574ff32e967454b0804bc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73656c6563746976652d7068702f73616d65736974652d636f6f6b69652e737667)](https://packagist.org/packages/selective/samesite-cookie)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)[![Build Status](https://github.com/selective-php/samesite-cookie/workflows/build/badge.svg)](https://github.com/selective-php/samesite-cookie/actions)[![Total Downloads](https://camo.githubusercontent.com/08c4d31e7f258572f176750d5d587149b5972e7a36515c9d0ebb203b0646d40c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73656c6563746976652f73616d65736974652d636f6f6b69652e737667)](https://packagist.org/packages/selective/samesite-cookie/stats)

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

[](#requirements)

- PHP 8.1 - 8.4

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

[](#installation)

```
composer require selective/samesite-cookie

```

SameSite cookies
----------------

[](#samesite-cookies)

[![image](https://user-images.githubusercontent.com/781074/64995066-95404c80-d8da-11e9-975f-bdbbf55bd311.png)](https://user-images.githubusercontent.com/781074/64995066-95404c80-d8da-11e9-975f-bdbbf55bd311.png)

Same-site cookies ("First-Party-Only" or "First-Party") allow servers to mitigate the risk of CSRF and information leakage attacks by asserting that a particular cookie should only be sent with requests initiated from the same registrable domain.

**Warning:** SameSite cookies doesn't work at all for old Browsers and also not for some Mobil Browsers e.g. IE 10, Blackberry, Opera Mini, IE Mobile, UC Browser for Android.

Further details can be found here:

- [SameSite cookies explained](https://web.dev/samesite-cookies-explained)
- [CSRF is (really) dead](https://scotthelme.co.uk/csrf-is-really-dead/)
- [PHP setcookie “SameSite=Strict”?](https://stackoverflow.com/questions/39750906/php-setcookie-samesite-strict)
- [How to Set a cookie attribute Samesite value in PHP ?](https://www.tutorialshore.com/how-to-set-a-cookie-attribute-samesite-value-in-php/)
- [Can I use SameSite?](https://caniuse.com/#feat=same-site-cookie-attribute)

Slim 4 integration
------------------

[](#slim-4-integration)

```
