Coder Social home page Coder Social logo

web-ex-machina / contao-page-cookie Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 40 KB

This bundle purpose is to protect a page with a cookie. It also provides the ability to generate the mentioned cookies through a form.

License: GNU General Public License v3.0

PHP 100.00%

contao-page-cookie's Introduction

Contao Page Cookie

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

  1. Create the usual structure of forms and pages inside Contao
  2. Inside the form, check the "Generate a cookie" checkbox
  3. 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.
  4. Check the box for the page you want to protected and indicate the cookie name you put inside the form.
  5. 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 name
  • cpcCookie_value - The cookie value
  • cpcCookie_duration - The cookie duration
  • cpcCookie_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

contao-page-cookie's People

Contributors

lupusvii avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.