Download the PHP package dutchheight/craft-cookie-boss without Composer

On this page you can find all versions of the php package dutchheight/craft-cookie-boss. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package craft-cookie-boss

Craft Cookie boss plugin for Craft CMS 3.x

Allow your visitors to set their cookie preference which you can use to enable features in your site. Create your own cookie groups, make them required and/or set their default state. These cookie groups can contain cookies with information which you can display to describe the purpose of each cookie.

The default modal contains the following features:

Modal with settings:

Modal settings:

Modal without settings:

Requirements

This plugin requires Craft CMS 3.0.0 or later.

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

    cd /path/to/project
  2. Then tell Composer to load the plugin:

    composer require dutchheight/craft-cookie-boss
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Craft Cookie boss.

  4. Add {{ craft.cookieBoss.askConsent() }} on the page(s) which should display the modal.

Using Craft Cookie boss

Display the consent modal

craft.cookieBoss.askConsent(options, force) is used to display the default consent modal.

Attribute Type Required Description
options object false Accepts position ('top or bottom-left or right')
force boolean false Force the modal

Examples

Display the modal

Display the modal in the top right corner

Display the modal always:


Display cookie descriptions

Display a table with all enabled cookies. The table has #cookie-descriptions as id. Each cookie is provided with the class .consent-true or .consent-false depending on the consentgroup's consent. All cookies are grouped by their group which has the class .cookie-descriptions-group-title. If you like more control you can use craft.cookieBoss.getCookiesRaw().

Examples

Display a table with all enabled cookies


Display cookie group toggle checkbox

Displays a checkbox which toggles the specified consent group. For more control see 'Toggle consent group with a form'

Attribute Type Required Description
handle string true Use a handle from the settings

Examples

Display a checkbox which can be used to toggle a consent group


Get all visitor consents

craft.cookieBoss.getConsents(defaultConcentIfNotSet) is used to get an array with the visitor's consents.

Attribute Type Required Description
defaultConcentIfNotSet boolean false return the default consents if the visitor doens't have any consents

Examples

Get all consents of the current visitor craft.cookieBoss.getConsents()

Get all consents of the current visitor. Get default values if noting found.


Get visitor consent date

craft.cookieBoss.getConsentGiveAt(format) is used to get the unix time or formated date of the visitor's consents.

Attribute Type Required Description
format string false Format the timestamp

Examples

Get the current visitor time of consent. craft.cookieBoss.getConsentGiveAt()

Get the current visitor time of consent in given format.


Get if visitor gave consent for cookie group

craft.cookieBoss.isConsentWith(handle) is used to get the consent of the current visitor by handle.

Attribute Type Required Description
handle string true Use a handle from the settings

Examples

Get consents of the current visitor


Get all consent groups

craft.cookieBoss.getConsentsGroupsRaw(false) is used to get all consent groups.

Attribute Type Required Description
onlyEnabled boolean false Only return enabled consent groups

Examples

Get all consent groups.


Get all consent groups by handle

craft.cookieBoss.getConsentsGroupRawByHandle(consentGroupHandle) is used to get all cookie groups by handle.

Attribute Type Required Description
consentGroupHandle string true Use a handle from the settings

Examples

Get all cookie groups by handle.


Get all cookie descriptions

craft.cookieBoss.getCookiesRaw() is used to get all cookie descriptions. craft.cookieBoss.getCookiesRaw(consentGroupHandle) is used to get all cookie descriptions for a consent group.

Attribute Type Required Description
consentGroupHandle string true Use a handle from the settings

Examples

Get all cookie descriptions


Custom modal

craft.cookieBoss.getConsentsGroupsRaw() will return all raw data which you can use to create a custom modal.

Save the settings

/craft-cookie-boss/save-consent-settings accepts POST requests with new consent settings. Usage of the Craft csrf token is required. Use craft.app.request.csrfParam to get the key and craft.app.request.csrfToken to get the actual token.

Attribute Type Required Description
toggled object true Use a handle from the settings
csrfParam string true Craft csrf token. Use the csrfParam as key

Example request data


Toggle a consent group with a custom form

Do a POST request to /cookie-boss/toggle-consent-group. For each group you wish to toggle you need to pass a boolean represented by the handle name.

Example form


Craft Cookie Boss Roadmap

Some things to do, and ideas for potential features:

Brought to you by Dutch Height


All versions of craft-cookie-boss with dependencies

PHP Build Version
Package Version
Requires craftcms/cms Version ^3.1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dutchheight/craft-cookie-boss contains the following files

Loading the files please wait ....