{"id":21076088,"url":"https://github.com/shaack/bootstrap-cookie-consent-settings","last_synced_at":"2025-05-16T06:32:03.864Z","repository":{"id":47634800,"uuid":"306348455","full_name":"shaack/bootstrap-cookie-consent-settings","owner":"shaack","description":"A modal dialog (cookie banner) and framework to handle the German and EU law about cookies in a website. Needs Bootstrap.","archived":false,"fork":false,"pushed_at":"2024-08-29T11:01:22.000Z","size":79,"stargazers_count":40,"open_issues_count":1,"forks_count":15,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-11-10T09:19:45.473Z","etag":null,"topics":["cookie-consent","cookie-options","cookie-settings","dialog","dsgvo","gdpr","gdpr-cookie"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/shaack.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":"2020-10-22T13:36:13.000Z","updated_at":"2024-08-29T11:01:25.000Z","dependencies_parsed_at":"2024-06-24T14:56:47.034Z","dependency_job_id":"490b1353-4795-4f19-a952-3af75839dff3","html_url":"https://github.com/shaack/bootstrap-cookie-consent-settings","commit_stats":{"total_commits":100,"total_committers":3,"mean_commits":"33.333333333333336","dds":"0.050000000000000044","last_synced_commit":"0f2061bd2afe297cb6756130b4e0d0187ba4eb71"},"previous_names":["shaack/bootstrap-cookie-banner"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaack%2Fbootstrap-cookie-consent-settings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaack%2Fbootstrap-cookie-consent-settings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaack%2Fbootstrap-cookie-consent-settings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaack%2Fbootstrap-cookie-consent-settings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shaack","download_url":"https://codeload.github.com/shaack/bootstrap-cookie-consent-settings/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224796859,"owners_count":17371561,"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-consent","cookie-options","cookie-settings","dialog","dsgvo","gdpr","gdpr-cookie"],"created_at":"2024-11-19T19:26:34.984Z","updated_at":"2025-05-16T06:32:03.848Z","avatar_url":"https://github.com/shaack.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bootstrap-cookie-consent-settings\n\nA modal dialog (cookie banner) and framework to handle the EU law (as written by EuGH, 1.10.2019 – C-673/17)\nabout cookies in a website. Needs Bootstrap 5.\n\n## References\n\n- [Demo page](https://shaack.com/projekte/bootstrap-cookie-consent-settings)\n- [GitHub Repository](https://github.com/shaack/bootstrap-cookie-consent-settings)\n- [npm package](https://www.npmjs.com/package/bootstrap-cookie-consent-settings)\n\n## Usage\n\n### Construct\n\nInitialize the cookie consent framework with the constructor\n\n```js\nvar cookieSettings = new BootstrapCookieConsentSettings(props)\n```\n\nYou should configure the framework with the `props` object, at least the properties `privacyPolicyUrl`, `legalNoticeUrl`\nand `contentURL`. The default configuration is\n\n```js\nthis.props = {\n    privacyPolicyUrl: undefined, // the URL of your privacy policy page\n    legalNoticeUrl: undefined, // the URL of you legal notice page (Impressum)\n    contentURL: \"/cookie-consent-content\", // this folder must contain the language-files in the needed languages (`[lang].js`)\n    buttonAgreeClass: \"btn btn-primary\", // the \"Agree to all\" buttons class\n    buttonDontAgreeClass: \"btn btn-link text-decoration-none\", // the \"I do not agree\" buttons class\n    buttonSaveClass: \"btn btn-secondary\", // the \"Save selection\" buttons class\n    autoShowModal: true, // disable autoShowModal on the privacy policy and legal notice pages, to make these pages readable\n    alsoUseLocalStorage: true, // if true, the settings are stored in localStorage, too\n    postSelectionCallback: undefined, // callback function, called after the user has saved the settings\n    lang: navigator.language, // the language, in which the modal is shown\n    defaultLang: \"en\", // default language, if `lang` is not available as translation in `cookie-consent-content`\n    categories: [\"necessary\", \"statistics\", \"marketing\", \"personalization\"], // the categories for selection, must be contained in the language files\n    cookieName: \"cookie-consent-settings\",  // the name of the cookie in which the configuration is stored as JSON\n    cookieStorageDays: 365, // the duration the cookie configuration is stored on the client\n    modalId: \"bootstrapCookieConsentSettingsModal\" // the id of the modal dialog element\n}\n```\n\n### Show dialog\n\nOn a new visit the dialog is shown automatically. \n\nTo allow the user a reconfiguration you can show the Dialog again with\n\n```js\ncookieSettings.showDialog()\n```\n\n### Read the settings in JavaScript\n\nRead all cookie settings with\n\n```js \ncookieSettings.getSettings()\n```\n\nIt should return some JSON like\n\n```json\n{\n  \"necessary\": true,\n  \"statistics\": true,\n  \"marketing\": true,\n  \"personalization\": true\n}\n```\n\nor `undefined`, before the user has chosen his cookie options.\n\nRead a specific cookie setting with\n\n```js\ncookieSettings.getSettings('statistics')\n```\n\nfor the `statistics` cookie settings. Also returns `undefined`, before the user has chosen his cookie options.\n\n### Read the settings from the backend\n\nYou can read the settings with all server languages, you just have to read the cookie `cookie-consent-settings`. \nThe content of the cookie is encoded like a http query string. \n\n``` \nnecessary=true\u0026statistics=false\u0026marketing=true\u0026personalization=true\n```\n\n#### PHP helper class\n\nI provide a PHP helper class that you can use to read and write the settings from a PHP backend.\n\nIt is located in `php/Shaack/BootstrapCookieConsentSettings.php`. \n\nYou can use it as described in the following example.\n\n```PHP\n$cookieSettings = new \\Shaack\\BootstrapCookieConsentSettings();\n// read all settings\n$allSettings = $cookieSettings-\u003egetSettings();\n// read a specific setting\n$statisticsAllowed = $cookieSettings-\u003egetSetting(\"statistics\");\n// write a specific setting\n$cookieSettings-\u003esetSetting(\"statistics\", false);\n```\n\n### Internationalization\n\nYou find the language files in `./cookie-consent-content`. You can add here language files or modify the existing. If\nyou add language files please consider a pull request to also add them in this repository. Thanks.\n\n## Disclaimer\n\nYou can use this banner for your website free of charge under the [MIT-License](./LICENSE).\n\nThe banner and framework was designed in cooperation with data protection officers and lawyers. However, we can not\nguarantee whether the banner is correct for your website and assume no liability for its use.\n\n---\n\nFind more high quality modules from [shaack.com](https://shaack.com)\non [our projects page](https://shaack.com/works).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaack%2Fbootstrap-cookie-consent-settings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshaack%2Fbootstrap-cookie-consent-settings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaack%2Fbootstrap-cookie-consent-settings/lists"}