webexmachina / contao-page-cookie
Contao Page Cookie bundle for Contao Open Source CMS
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Type:contao-bundle
Requires
- contao/core-bundle: ^4.13
- terminal42/notification_center: ^1.6
README
This bundle adds a page protection by cookie to Contao Open Source CMS. It means a page cannot been reached until the device does not have a specific cookie. This bundle also provides the ability to generate that cookie, using Contao Forms.
Install
Use composer to install this bundle: composer require webexmachina/contao-page-cookie
Or simpler: use the Contao Manager.
Bundle configuration
- Create the usual structure of forms and pages inside Contao
- Inside the form, check the "Generate a cookie" checkbox
- Fill values as needed. Note that there is two options, a cookie can be generated directly when the form is submitted or when the GET token is catched in the URL.
- Check the box for the page you want to protected and indicate the cookie name you put inside the form.
- That's it! The page is now protected by a cookie.
Notification Center
This bundle extends a little bit the tokens from Notification Center core_form
notification. You can use the following tokens:
cpcCookie_name
- The cookie namecpcCookie_value
- The cookie valuecpcCookie_duration
- The cookie durationcpcCookie_token
- The cookie token
With the cookie token, you just have to add it as an URL argument, like {{link_url::x}}?cpc_cookieToken=##cpcCookie_token##
. Since the cookie detection is on the initializeSystem
hook, every page can validate the cookie. So you can redirect directly to the page you want to protect.
Useful links
You can consult the Changelog here or submit issues in the Github section.
Possible enhancements
- Use php session instead of database query to retrieve last form cookie generated (and pass the token to use as cookie value)
- Add a cronjob to remove FormCookie entries (because either they have been already generated or they are not valid anymore)
- Apply cookie protection behavior to every protected element, and not only pages
- Add English translations
- Allow settings to use dynamic vars from the data sent through the form