orestbida / cookieconsent

:cookie: Simple cross-browser cookie-consent plugin written in vanilla js

Home Page:https://playground.cookieconsent.orestbida.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feat]: Store consent using localStorage or other techniques

boldtrn opened this issue · comments

Description

Right now cookieconsent is using cookies. It would be great if instead of cookies it would be possible to use other methods like localStorage.

Proposed solution

Provide a config option for cookie like storage and provide different options like localstorage.

Additional details

We are working with webviews for mobile apps quite a bit. Especially on iOS webviews tend to drop cookies on close, whereas other technology persits fine. We work with indexeddb and localstorage and both seem to work significantly better than cookies.

An option like cookie.useLocalStorage should be enough in my opinion:

cookie?: {
    name?: string,
    domain?: string,
    path?: string,
    expiresAfterDays?: number | (acceptType: string) => number,
    sameSite?: string,
    useLocalStorage?: true
}

When using localstorage, options such as domain, path and sameSite will be ignored.

Yes indeed, that would be great. Thanks for considering it 👍

Just wanted to say thank you for the quick fix. I can verify that the current v3 branch works fine on webviews as well.