{"id":26085262,"url":"https://github.com/codezero-be/cookie","last_synced_at":"2025-04-12T02:01:18.515Z","repository":{"id":29498504,"uuid":"33036325","full_name":"codezero-be/cookie","owner":"codezero-be","description":"Your friendly, furry cookie monster. Get and set cookies with ease!","archived":false,"fork":false,"pushed_at":"2019-09-27T16:31:47.000Z","size":30,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T21:47:11.685Z","etag":null,"topics":["cookie","cookies","encryption","laravel","php","vanilla-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/codezero-be.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-28T14:29:33.000Z","updated_at":"2023-06-11T11:46:23.000Z","dependencies_parsed_at":"2022-08-21T08:50:33.405Z","dependency_job_id":null,"html_url":"https://github.com/codezero-be/cookie","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codezero-be%2Fcookie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codezero-be%2Fcookie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codezero-be%2Fcookie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codezero-be%2Fcookie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codezero-be","download_url":"https://codeload.github.com/codezero-be/cookie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248208467,"owners_count":21065199,"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":["cookie","cookies","encryption","laravel","php","vanilla-php"],"created_at":"2025-03-09T05:58:02.013Z","updated_at":"2025-04-12T02:01:18.431Z","avatar_url":"https://github.com/codezero-be.png","language":"PHP","funding_links":["https://ko-fi.com/R6R3UQ8V"],"categories":[],"sub_categories":[],"readme":"# PHP Cookies\n\n[![GitHub release](https://img.shields.io/github/release/codezero-be/cookie.svg)]()\n[![License](https://img.shields.io/packagist/l/codezero/cookie.svg)]()\n[![Build Status](https://scrutinizer-ci.com/g/codezero-be/cookie/badges/build.png?b=master)](https://scrutinizer-ci.com/g/codezero-be/cookie/build-status/master)\n[![Code Coverage](https://scrutinizer-ci.com/g/codezero-be/cookie/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/codezero-be/cookie/?branch=master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/codezero-be/cookie/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/codezero-be/cookie/?branch=master)\n[![Total Downloads](https://img.shields.io/packagist/dt/codezero/cookie.svg)](https://packagist.org/packages/codezero/cookie)\n\n[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R3UQ8V)\n\n### Your friendly, furry cookie monster!\n\nGet and set cookies in vanilla PHP with ease.\nA [Laravel](http://laravel.com/) implementation is included, but this has no real advantages if you only use Laravel.\n\n**CAUTION!** Never store sensitive data in a cookie!\n\n## Installation\n\nInstall this package through Composer:\n\n```php\ncomposer require codezero/cookie\n```\n\n## Vanilla PHP Implementation\n\nAutoload the vendor classes:\n\n```php\nrequire_once 'vendor/autoload.php'; // Path may vary\n```\n\nAnd then use the `VanillaCookie` implementation:\n\n```php\n$cookie = new \\CodeZero\\Cookie\\VanillaCookie();\n```\n\nIf you want your cookies to be encrypted, pass an instance of [codezero/encrypter](https://github.com/codezero-be/encrypter) to the `Cookie` class.\nYou will also need to provide it with an encryption key that is needed to decrypt the cookie later on.\n\n```php\n$key = 'my secret app key';\n$encrypter = new \\CodeZero\\Encrypter\\DefaultEncrypter($key);\n$cookie = new \\CodeZero\\Cookie\\VanillaCookie($encrypter);\n```\n\n\u003e **TIP:** Laravel automagically encrypts cookies by default!\n\n## Laravel 5 Implementation\n\nYou can \"make\" (or inject) a `Cookie` instance anywhere in your app:\n\n```php\n$cookie = \\App::make('CodeZero\\Cookie\\Cookie');\n```\n\n\u003e **TIP:** Laravel's [IoC container](http://laravel.com/docs/container) will automatically provide the Laravel specific `Cookie` implementation.\n\u003e This will use Laravel's [`Cookie`](http://laravel.com/docs/requests) goodness behind the scenes!\n\n## Usage\n\n### Get a cookie\n\nThis will return `null` if the cookie doesn't exist or is expired.\n\n```php\n$cookieValue = $cookie-\u003eget('cookieName');\n```\n\n### Store a cookie for a limited time\n\nIf you don't specify `$minutesValid`, a default of 60 minutes will be used.\n\n```php\n$minutesValid = 120;\n$cookie-\u003estore('cookieName', 'cookieValue', $minutesValid);\n```\n\n### Store a cookie forever\n\n5 years feels like forever... ;)\n\n```php\n$cookie-\u003eforever('cookieName', 'cookieValue');\n```\n\n### Delete a cookie\n\nIf the cookie doesn't exist, nothing will happen...\n\n```php\n$cookie-\u003edelete('cookieName');\n```\n\n### Check if a cookie exists\n\nYou can check if a cookie exists.\nHowever, keep in mind that a cookie will not be available immediately.\nIt will be on the next page load.\n\n```php\nif ($cookie-\u003eexists('cookieName')) {\n    // The cookie exists!\n}\n```\n\n## Testing\n\n```php\n$ composer run test\n```\n\n## Security\n\nIf you discover any security related issues, please [e-mail me](mailto:ivan@codezero.be) instead of using the issue tracker.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodezero-be%2Fcookie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodezero-be%2Fcookie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodezero-be%2Fcookie/lists"}