{"id":21429383,"url":"https://github.com/nystudio107/cookies","last_synced_at":"2025-07-14T10:32:56.300Z","repository":{"id":31004023,"uuid":"34562430","full_name":"nystudio107/cookies","owner":"nystudio107","description":"DEPRECATED Secure Cookies for Twig Templates in Craft CMS","archived":false,"fork":false,"pushed_at":"2019-01-01T23:34:25.000Z","size":18,"stargazers_count":68,"open_issues_count":0,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-05-01T12:57:08.469Z","etag":null,"topics":["cookies","craft-plugin","craft3","craftcms"],"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/nystudio107.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-25T09:15:11.000Z","updated_at":"2024-02-01T20:57:30.000Z","dependencies_parsed_at":"2022-08-26T08:21:42.255Z","dependency_job_id":null,"html_url":"https://github.com/nystudio107/cookies","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nystudio107%2Fcookies","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nystudio107%2Fcookies/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nystudio107%2Fcookies/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nystudio107%2Fcookies/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nystudio107","download_url":"https://codeload.github.com/nystudio107/cookies/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225970889,"owners_count":17553411,"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","craft-plugin","craft3","craftcms"],"created_at":"2024-11-22T22:17:36.623Z","updated_at":"2024-11-22T22:17:37.269Z","avatar_url":"https://github.com/nystudio107.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)\n\n# DEPRECATED\n\nThis Craft CMS 2.x plugin is no longer supported, but it is fully functional, and you may continue to use it as you see fit. The license also allows you to fork it and make changes as needed for legacy support reasons.\n\nThe Craft CMS 3.x version of this plugin can be found here: [craft-cookies](https://github.com/nystudio107/craft-cookies) and can also be installed via the Craft Plugin Store in the Craft CP.\n\n# Cookies plugin for Craft CMS\n\nA simple plugin for setting and getting cookies from within [Craft CMS](http://buildwithcraft.com) templates.\n\nRelated: [Cookies for Craft 3.x](https://github.com/nystudio107/craft3-cookies)\n\nThis plugin is inspired the [Lj_cookies](https://github.com/lewisjenkins/craft-lj-cookies) plugin, and functions similarly, but adds the ability to get and set secure cookies using the craft-\u003esecurity() framework, and it also provides Twig filters and functions as well as Craft variables for setting \u0026 getting cookies.\n\n**Installation**\n\n1. Download \u0026 unzip the file and place the `cookies` directory into your `craft/plugins` directory\n2.  -OR- do a `git clone https://github.com/khalwat/cookies.git` directly into your `craft/plugins` folder.  You can then update it with `git pull`\n3. Install plugin in the Craft Control Panel under Settings \u003e Plugins\n4. The plugin folder should be named `cookies` for Craft to see it.  GitHub recently started appending `-master` (the branch name) to the name of the folder for zip file downloads.\n\n## Setting cookies\n\nAll three of these methods accomplish the same thing:\n\n\t{# Set the cookie using 'setCookie' function #}\n    {{ setCookie( NAME, VALUE, DURATION, PATH, DOMAIN, SECURE, HTTPONLY) }}\n    \n\t{# Set the cookie using 'setCookie' filter #}\n    {{ NAME | setCookie( VALUE, DURATION, PATH, DOMAIN, SECURE, HTTPONLY) }}\n\n\t{# Set the cookie using 'set' variable #}\n    {% do craft.cookies.set( NAME, VALUE, DURATION, PATH, DOMAIN, SECURE, HTTPONLY) %}\n\nThey all act as a wrapper for the PHP `setcookie` function:\n\nMore info: (http://php.net/manual/en/function.setcookie.php)\n\nAll of the parameters except for `NAME` are optional.  The `PATH` defaults to `/` if not specified\n\n**Examples**\n\n    {{ setCookie('marvin', 'martian', now | date_modify(\"+1 hour\").timestamp ) }}\n    {# Sets a cookie to expire in an hour. #}\n\n    {% 'marvin' | setCookie('martian', now | date_modify(\"+30 days\").timestamp ) %}\n    {# Sets a cookie to expire in 30 days. #}\n\t\n    {% do craft.cookies.set('marvin', 'martian', '', '/foo/' ) %}\n    {# Cookie available within /foo/ directory and sub-directories. #}\n\n## Setting Secure cookies\n\nAll three of these methods accomplish the same thing:\n\n\t{# Set the cookie using 'setSecureCookie' function #}\n    {{ setSecureCookie( NAME, VALUE, DURATION, PATH, DOMAIN, SECURE, HTTPONLY) }}\n    \n\t{# Set the cookie using 'setSecureCookie' filter #}\n    {{ NAME | setSecureCookie( VALUE, DURATION, PATH, DOMAIN, SECURE, HTTPONLY) }}\n\n\t{# Set the cookie using 'setSecure' variable #}\n    {% do craft.cookies.setSecure( NAME, VALUE, DURATION, PATH, DOMAIN, SECURE, HTTPONLY) %}\n\nThis function works the same as `setCookie` but instead of using the PHP `setcookie` function, it uses the `craft()-\u003erequest-\u003egetCookies()-\u003eadd` to add the cookies via Craft.  It also utilizes `craft-\u003esecurity` framework to encrypt and validate the cookie contents between requests.\n\nAll of the parameters except for `NAME` are optional.  The `PATH` defaults to `/` if not specified\n\n**Examples**\n\n    {{ setSecureCookie('marvin', 'martian', now | date_modify(\"+1 hour\").timestamp ) }}\n    {# Sets a cookie to expire in an hour. #}\n\n    {{ 'marvin' | setSecureCookie('martian', now | date_modify(\"+30 days\").timestamp ) }}\n    {# Sets a cookie to expire in 30 days. #}\n\t\n    {% do craft.cookies.setSecure('marvin', 'martian', '', '/foo/' ) %}\n    {# Cookie available within /foo/ directory and sub-directories. #}\n\n## Retrieving cookies\n\nBoth of these methods accomplish the same thing:\n\n\t{# Get the cookie using 'getCookie' function #}\n    {{ getCookie( NAME ) }}\n    \n\t{# Get the cookie using 'get' variable #}\n    {% do craft.cookies.get( NAME ) %}\n\n**Example**\n\n    {{ getCookie('marvin') }}\n\t{# Get the cookie using 'getCookie' function #}\n\n    {{ craft.cookies.get('marvin') }}\n\t{# Get the cookie using 'get' variable #}\n\n\t{% if getCookie('marvin') %}\n\t\t{% set myCookie = getCookie('marvin') %}\n\t\t{{ myCookie }}\n\t{% endif %}\n\n## Retrieving Secure cookies\n\nBoth of these methods accomplish the same thing:\n\n\t{# Get the cookie using 'getSecureCookie' function #}\n    {{ getSecureCookie( NAME ) }}\n    \n\t{# Get the cookie using 'getSecure' variable #}\n    {% do craft.cookies.getSecure( NAME ) %}\n\n**Example**\n\n    {{ getSecureCookie('marvin') }}\n\t{# Get the cookie using 'getSecureCookie' function #}\n\n    {{ craft.cookies.getSecure('marvin') }}\n\t{# Get the cookie using 'getSecure' variable #}\n\n\t{% if getSecureCookie('marvin') %}\n\t\t{% set myCookie = getSecureCookie('marvin') %}\n\t\t{{ myCookie }}\n\t{% endif %}\n\nThis function works the same as `getCookie` but it uses `craft()-\u003erequest-\u003egetCookie()` to retrieve the cookies via Craft.  It also utilizes `craft-\u003esecurity` framework to decrypt and validate the cookie contents between requests.\n\n**Example**\n\n    {{ getSecureCookie('marvin') }}\n\t{# Get the cookie using 'getSecureCookie' function #}\n\n    {{ craft.cookies.getSecure('marvin') }}\n\t{# Get the cookie using 'getSecure' variable #}\n\n\t{% if getSecureCookie('marvin') %}\n\t\t{% set myCookie = getSecureCookie('marvin') %}\n\t\t{{ myCookie }}\n\t{% endif %}\n\t\n## Deleting cookies\n\nAll three of these methods accomplish the same thing:\n\n\t{# Delete a cookie by passing no VALUE to 'setCookie' function #}\n    {{ setCookie( NAME ) }}\n    \n\t{# Delete a cookie by passing no VALUE to 'setCookie' filter #}\n    {{ NAME | setCookie() }}\n\n\t{# Delete a cookie by passing no VALUE to 'set' variable #}\n    {% do craft.cookies.set( NAME ) %}\n\n## Deleting Secure cookies\n\nAll three of these methods accomplish the same thing:\n\n\t{# Delete a cookie by passing no VALUE to 'setSecureCookie' function #}\n    {{ setSecureCookie( NAME ) }}\n    \n\t{# Delete a cookie by passing no VALUE to 'setSecureCookie' filter #}\n    {{ NAME | setSecureCookie() }}\n\n\t{# Delete a cookie by passing no VALUE to 'setSecure' variable #}\n    {% do craft.cookies.setSecure( NAME ) %}\n\n## Changelog\n\n### 1.0.4 -- 2016.04.06\n\n* [Fixed] Saner default values for cookies\n* [Improved] Updated the README.md\n\n### 1.0.3 -- 2016.03.08\n\n* [Fixed] We now set the expiration date to the past if we're deleting a cookie, to force browsers to remove it\n* [Improved] Updated the README.md\n\n### 1.0.2 -- 2015.11.23\n\n* Added support for Craft 2.5 new plugin features\n* Updated the README.md\n\n### 1.0.1 -- 2015.04.25\n\n* Added Twig filters and functions for setting/getting cookies\n* Moved the core functionality to services\n* Updated the documentation\n\n### 1.0.0 -- 2015.04.24\n\n* Initial release\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnystudio107%2Fcookies","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnystudio107%2Fcookies","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnystudio107%2Fcookies/lists"}