[FEATURE] Make cookie use optional
Closed this issue · 8 comments
At the moment, per default one cookie (or local storage) is used to allow the user to store the dark/light theme selection.
It would perhaps make sense to have an option to avoid this (even if that means only the auto theme selection is possible), as this would allow to use the theme without the cookie banner.
If I missed how to do this now already, sorry, I read a bit the code and for me this seems at the moment to be unconditional.
Agreed this would be a good and would remove the need to have any cookies. Just wondering if any update on this?
Hi all,
I looked at this item and I did the following:
If the params.cookieconsent.enable
is false
, then the theme
option will not be written in the local storage.
Can you look at these modifications and share the opinion if the changes are ok?
Hi,
I think is best test against this.config.cookieconsent
:
this.config.cookieconsent && window.localStorage &&
localStorage.setItem("theme", this.isDark ? "dark" : "light");
layouts/partials/assets.html
only set this.config.cookieconsent
if params.cookienconsent.enabled
is true.
If it is false, this.config.cookieconsent
is undefined.
Hi @aplatanado,
If the this.config.cookieconsent
property will be undefined, the theme key in the localStorage will not be set (as expected).
Can you explain please what do you mean?
Thanks. 😉
Hi,
If the condition is:
this.config.cookieconsent.enable && ....
then that line will fail with 'Uncaught TypeError: Cannot read property 'enabled' of undefined' when there is no 'cookieconsent' section in config file or enabled was set to false because in both cases this.config.cookieconsent is undefined. So I suggest just checking if this.config.cookieconsent is not undefined, as in:
Ohh, understood you, I don't know where I looked in code yesterday because I remember only the this.config.cookieconsent
(without enable). My mistake, sorry ))
I added your review in PR #207.
Hmm, I must confess, I tried this, but for me, still the local storage is set, with 0.2.0, even without cookie banner.
Perhaps I am doing something wrong.
@christoph-cullmann have you tried to disable the cookie consent?
# Cookie consent config
[params.cookieconsent]
enable = false