Socket
Socket
Sign inDemoInstall

cookieyesno

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cookieyesno

Easy to use GDPR-complient cookie-banner


Version published
Maintainers
1
Created

Readme

Source

cookieyesno

Easy to use GDPR-complient cookie-banner

Take a look at it in action on a real site: https://watchaccuracy.com/

Usage

// using packages
import CookieYesNo from 'cookieyesno';

// or simply include the dist/cookieyesno.min.js file in the html

const cyn = new CookieYesNo({
	text: 'This website uses cookies. You can select below which cookies will be stored on your device.',
    cookiePolicy: '<LINK TO YOUR COOKIE POLICY>',
    categories: {                   // different categories of cookies
        required: {
            allowed: true,          // preselected
            description: 'These cookies are necessary for the website to function properly.',
            changeable: false       // user can not change this option
        },
        Analytics: {
            allowed: false,         // not preselected
            description: 'These cookies are used to analyze the user\'s behavior.'
        }
    }
});

cyn.onChange((settings) => {
    // cookie settings have changed
});

// Note: all categories are transformed to lowercase (Analytics -> analytics)
cyn.onAccept('analytics', () => {
    // analytics-cookies are accepted
});

cyn.onReject('analytics', () => {
    // analytics-cookies are not allowed
});

// get current cookie settings
cyn.getSettings(); // example-response { required: true, analytics: false }

cyn.reviewSettings();       // open the banner to let the user review the settings

Modify the banner

It's pretty simple: just use CSS-rules. The following classes are available:

  • .cyn-banner: main banner element
  • .cyn-categories: table containing the different cookie categories
  • .cyn-btn-save: save settings button
  • .cyn-btn-accept-all: accept all button

Keywords

FAQs

Last updated on 07 Mar 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc