{"id":19665914,"url":"https://github.com/amphp/http-client-cookies","last_synced_at":"2025-08-07T23:06:40.169Z","repository":{"id":40523516,"uuid":"191177010","full_name":"amphp/http-client-cookies","owner":"amphp","description":"Automatic cookie handling for Amp's HTTP client.","archived":false,"fork":false,"pushed_at":"2023-10-08T17:31:14.000Z","size":211,"stargazers_count":13,"open_issues_count":0,"forks_count":4,"subscribers_count":7,"default_branch":"2.x","last_synced_at":"2025-07-05T13:47:55.367Z","etag":null,"topics":["cookiejar","cookies","http","http-client","php"],"latest_commit_sha":null,"homepage":null,"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/amphp.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-06-10T13:49:54.000Z","updated_at":"2025-04-23T16:42:46.000Z","dependencies_parsed_at":"2024-06-18T18:24:53.892Z","dependency_job_id":"3f117396-5a78-4361-8adf-a81bd3264ec7","html_url":"https://github.com/amphp/http-client-cookies","commit_stats":{"total_commits":57,"total_committers":6,"mean_commits":9.5,"dds":"0.26315789473684215","last_synced_commit":"4124b37ffa4d15034e70d5d30e6fb9605ed6c1a7"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/amphp/http-client-cookies","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amphp%2Fhttp-client-cookies","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amphp%2Fhttp-client-cookies/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amphp%2Fhttp-client-cookies/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amphp%2Fhttp-client-cookies/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amphp","download_url":"https://codeload.github.com/amphp/http-client-cookies/tar.gz/refs/heads/2.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amphp%2Fhttp-client-cookies/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269338065,"owners_count":24400180,"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","status":"online","status_checked_at":"2025-08-07T02:00:09.698Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cookiejar","cookies","http","http-client","php"],"created_at":"2024-11-11T16:25:26.377Z","updated_at":"2025-08-07T23:06:40.134Z","avatar_url":"https://github.com/amphp.png","language":"PHP","readme":"# amphp/http-client-cookies\n\nAMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind.\nThis package provides automatic cookie handling as a plugin for [`amphp/http-client`](https://github.com/amphp/http-client).\n\n## Installation\n\nThis package can be installed as a [Composer](https://getcomposer.org/) dependency.\n\n```bash\ncomposer require amphp/http-client-cookies\n```\n\n## Usage\n\n`Amp\\Http\\Client\\Cookie\\CookieInterceptor` must be registered as a `NetworkInterceptor` to enable automatic cookie handling.\nIt requires a `CookieJar` implementation, where you can choose between `LocalCookieJar`, `FileCookieJar`, and `NullCookieJar`.\n\n```php\n\u003c?php\n\nuse Amp\\Http\\Client\\Cookie\\CookieInterceptor;\nuse Amp\\Http\\Client\\Cookie\\LocalCookieJar;\nuse Amp\\Http\\Client\\HttpClientBuilder;\nuse Amp\\Http\\Client\\Request;\nuse Amp\\Http\\Client\\Response;\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n$cookieJar = new LocalCookieJar;\n\n$httpClient = (new HttpClientBuilder)\n    -\u003einterceptNetwork(new CookieInterceptor($cookieJar))\n    -\u003ebuild();\n\n$firstResponse = $httpClient-\u003erequest(new Request('https://google.com/'));\n$firstResponse-\u003egetBody()-\u003ebuffer();\n\n$secondResponse = $httpClient-\u003erequest(new Request('https://google.com/'));\n$secondResponse-\u003egetBody()-\u003ebuffer();\n\n$otherDomainResponse = $httpClient-\u003erequest(new Request('https://amphp.org/'));\n$otherDomainResponse-\u003egetBody()-\u003ebuffer();\n\nprint \"== first response stores cookies ==\\r\\n\";\nprint \\implode(\"\\r\\n\", $firstResponse-\u003egetHeaderArray('set-cookie'));\nprint \"\\r\\n\\r\\n\";\n\nprint \"== second request sends cookies again ==\\r\\n\";\nprint \\implode(\"\\r\\n\", $secondResponse-\u003egetRequest()-\u003egetHeaderArray('cookie'));\nprint \"\\r\\n\\r\\n\";\n\nprint \"== other domain request does not send cookies ==\\r\\n\";\nprint \\implode(\"\\r\\n\", $otherDomainResponse-\u003egetRequest()-\u003egetHeaderArray('cookie'));\n```\n\n## Examples\n\nMore extensive code examples reside in the [`examples`](./examples) directory.\n\n## Versioning\n\n`amphp/http-client-cookies` follows the [semver](http://semver.org/) semantic versioning specification like all other `amphp` packages.\n\n## Security\n\nIf you discover any security related issues, please email [`me@kelunik.com`](mailto:me@kelunik.com) instead of using the issue tracker.\n\n## License\n\nThe MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information.\n","funding_links":[],"categories":["HTTP"],"sub_categories":["Client"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famphp%2Fhttp-client-cookies","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famphp%2Fhttp-client-cookies","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famphp%2Fhttp-client-cookies/lists"}