{"id":20672781,"url":"https://github.com/selective-php/samesite-cookie","last_synced_at":"2025-04-19T19:11:04.245Z","repository":{"id":45403292,"uuid":"207655087","full_name":"selective-php/samesite-cookie","owner":"selective-php","description":"Secure your site with SameSite cookies","archived":false,"fork":false,"pushed_at":"2023-09-09T21:31:39.000Z","size":26,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T12:05:06.368Z","etag":null,"topics":["cookies","csrf","php","samesite-cookies"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/selective-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-10T20:18:26.000Z","updated_at":"2022-02-07T01:42:03.000Z","dependencies_parsed_at":"2024-06-19T19:06:13.974Z","dependency_job_id":"ceaa2ce2-a716-4041-845e-e0379397ebbc","html_url":"https://github.com/selective-php/samesite-cookie","commit_stats":{"total_commits":26,"total_committers":3,"mean_commits":8.666666666666666,"dds":"0.11538461538461542","last_synced_commit":"33eae10834d8926867ab99366a21fcc710ff7368"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selective-php%2Fsamesite-cookie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selective-php%2Fsamesite-cookie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selective-php%2Fsamesite-cookie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selective-php%2Fsamesite-cookie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/selective-php","download_url":"https://codeload.github.com/selective-php/samesite-cookie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248714736,"owners_count":21149958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cookies","csrf","php","samesite-cookies"],"created_at":"2024-11-16T20:38:46.881Z","updated_at":"2025-04-19T19:11:04.203Z","avatar_url":"https://github.com/selective-php.png","language":"PHP","readme":"# selective/samesite-cookie\n\nA PSR-15 middleware to secure your site with SameSite cookies :cookie:\n\n[![Latest Version on Packagist](https://img.shields.io/github/release/selective-php/samesite-cookie.svg)](https://packagist.org/packages/selective/samesite-cookie)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)\n[![Build Status](https://github.com/selective-php/samesite-cookie/workflows/build/badge.svg)](https://github.com/selective-php/samesite-cookie/actions)\n[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/selective-php/samesite-cookie.svg)](https://scrutinizer-ci.com/g/selective-php/samesite-cookie/code-structure)\n[![Quality Score](https://img.shields.io/scrutinizer/quality/g/selective-php/samesite-cookie.svg)](https://scrutinizer-ci.com/g/selective-php/samesite-cookie/?branch=master)\n[![Total Downloads](https://img.shields.io/packagist/dt/selective/samesite-cookie.svg)](https://packagist.org/packages/selective/samesite-cookie/stats)\n\n\n## Requirements\n\n* PHP 8.1+\n\n## Installation\n\n```\ncomposer require selective/samesite-cookie\n```\n\n## SameSite cookies\n\n![image](https://user-images.githubusercontent.com/781074/64995066-95404c80-d8da-11e9-975f-bdbbf55bd311.png)\n\nSame-site cookies (\"First-Party-Only\" or \"First-Party\") allow servers to mitigate \nthe risk of CSRF and information leakage attacks by asserting that a particular \ncookie should only be sent with requests initiated from the same registrable domain.\n\n**Warning:** SameSite cookies doesn't work at all for old Browsers and \nalso not for some Mobil Browsers e.g. IE 10, Blackberry, Opera Mini, \nIE Mobile, UC Browser for Android.\n\nFurther details can be found here:\n\n* [SameSite cookies explained](https://web.dev/samesite-cookies-explained)\n* [CSRF is (really) dead](https://scotthelme.co.uk/csrf-is-really-dead/)\n* [PHP setcookie “SameSite=Strict”?](https://stackoverflow.com/questions/39750906/php-setcookie-samesite-strict)\n* [How to Set a cookie attribute Samesite value in PHP ?](https://www.tutorialshore.com/how-to-set-a-cookie-attribute-samesite-value-in-php/)\n* [Can I use SameSite?](https://caniuse.com/#feat=same-site-cookie-attribute)\n\n## Slim 4 integration\n\n```php\n\u003c?php\n\nuse Selective\\SameSiteCookie\\SameSiteCookieMiddleware;\nuse Slim\\Factory\\AppFactory;\n\n$app = AppFactory::create();\n\n// ...\n\n// Register the samesite cookie middleware\n$app-\u003eadd(new SameSiteCookieMiddleware());\n\n// ...\n\n$app-\u003erun();\n```\n\n**Example with configuration and the session starter middleware.**\n\nSlim 4 uses a LIFO (last in, first out) middleware stack,\nso we have to add the middleware in reverse order:\n\n```php\n\u003c?php\n\nuse Selective\\SameSiteCookie\\SameSiteCookieConfiguration;\nuse Selective\\SameSiteCookie\\SameSiteCookieMiddleware;\nuse Selective\\SameSiteCookie\\SameSiteSessionMiddleware;\nuse Slim\\Factory\\AppFactory;\n\n$app = AppFactory::create();\n\n// ...\n\n// Optional: Add custom configuration\n$configuration = new SameSiteCookieConfiguration();\n\n// Register the samesite cookie middleware\n$app-\u003eadd(new SameSiteCookieMiddleware($configuration));\n\n// Optional: Start the PHP session\n// Use this middleware only if you have no other session starter middleware\n$app-\u003eadd(new SameSiteSessionMiddleware());\n\n// ...\n\n$app-\u003erun();\n```\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselective-php%2Fsamesite-cookie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fselective-php%2Fsamesite-cookie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselective-php%2Fsamesite-cookie/lists"}