{"id":19952064,"url":"https://github.com/studio24/cookie-message","last_synced_at":"2025-03-01T15:15:31.759Z","repository":{"id":72851212,"uuid":"61115574","full_name":"studio24/cookie-message","owner":"studio24","description":"Simple code to display the EU Cookie law message once only","archived":false,"fork":false,"pushed_at":"2019-05-13T11:49:16.000Z","size":8,"stargazers_count":54,"open_issues_count":1,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-25T18:04:52.126Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","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/studio24.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2016-06-14T10:57:54.000Z","updated_at":"2024-02-29T23:44:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"bd48cbea-80d0-45e9-a0a8-07ad6178f6b0","html_url":"https://github.com/studio24/cookie-message","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studio24%2Fcookie-message","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studio24%2Fcookie-message/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studio24%2Fcookie-message/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studio24%2Fcookie-message/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/studio24","download_url":"https://codeload.github.com/studio24/cookie-message/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241381646,"owners_count":19953751,"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":[],"created_at":"2024-11-13T01:11:23.670Z","updated_at":"2025-03-01T15:15:31.751Z","avatar_url":"https://github.com/studio24.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cookie message \n\nA simple snippet of HTML and JavaScript to manage the cookie message that is required by EU Cookie Law. This is inspired\nby the GOV.UK site that simply displays a message and then hides it on the next page request.\n\nThe Information Commissioner's Office (ICO) state that implied consent is OK for things like Google Analytics. Quite \nhonestly they wouldn't work without them! The main requirement is for UK websites to display clear information about cookies to their users, \nwhich is a good idea in any case.\n\n## What you need to do\n\nWe recommend the minimum requirement is to have a Cookie Policy clearly explaining your usage of cookies. You can see an example\nof a cookie policy in the file [cookie-policy.html](cookie-policy.html)\n\nOptionally, you can also have a cookie message displaying at the top of your website. \n\n## Usage\n\nAdd the cookie message HTML at the top of your page. You can add whatever message you like and include a link to your \ncookie or privacy policy. There's no close link.\n\n```html\n\u003cdiv id=\"cookie-message\"\u003e\n    \u003cp\u003e\n        Your cookie message goes here\n    \u003c/p\u003e\n\u003c/div\u003e\n```\n\nAdd this JavaScript after the body tag to instantly apply the js_enabled class. This ensures the cookie message is hidden without a flash of content.\n\n```html\n\u003cscript\u003e\n    // Detect JS support\n    document.body.className = document.body.className + \" js_enabled\";\n\u003c/script\u003e\n```\n\nYou need this CSS to ensure the cookie message is initially hidden if JavaScript is supported. Without this there will be \na flash of content as the cookie message appears and then is hidden after the DOM has loaded.\n\n```css\n.js_enabled #cookie-message {\n    display: none;\n}\n```\n\nLoad this JavaScript at the bottom of the page to hide the cookie message after the first view (yes, this sets a cookie to hide the cookie message).\n\n```html\n\u003cscript src=\"cookie-message.js\"\u003e\u003c/script\u003e\n```\n\n### Changing the cookie path\n\nBy default the cookie to hide the message is set across the entire current domain. If you want to set the cookie on a sub-folder \npath only, for example if you have a set of sub-sites and you want the cookie warning to appear for each one, then you can \nset the cookie path via the `data-cookie-path` attribute. \n\n```html\n\u003cdiv id=\"cookie-message\" data-cookie-path=\"/my-site\"\u003e\n    ...\n\u003c/div\u003e\n``` \n\nPlease note if you set a cookie warning on both the domain root and a sub-path, the cookie saved to the domain root will stop\nthe cookie message displaying on sub-path pages.\n\n### Extending cookie lifetime\n\nBy default the cookie message is displayed once, a cookie is then set to hide it for 30 days. If the user does not visit \nthe site again in over 30 days then they will see the cookie message once more the next time they visit. Each time the user \nvisits the site the cookie is updated and the 30 day expiry reset.\n\nYou can extend the cookie lifetime via the `data-cookie-expiry` data attribute, for example:\n\n```html\n\u003cdiv id=\"cookie-message\" data-cookie-expiry=\"60\"\u003e\n    ...\n\u003c/div\u003e\n```\n\n## More information\n\nWe wrote an article on the [Cookie Law](http://www.studio24.net/blog/clarification-on-cookie-law/) which you can read on our website.\n\nYou can also find out more from the [Information Commissioner's Office](https://ico.org.uk/for-organisations/guide-to-pecr/cookies-and-similar-technologies/).\n \n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n## Credits\n\n- [Simon R Jones](https://github.com/simonrjones)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstudio24%2Fcookie-message","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstudio24%2Fcookie-message","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstudio24%2Fcookie-message/lists"}