shopware6shopware6-app

Shopware6 Register required(technical) cookies for app


I am currently working on a payment app with Stripe services. This app uses javascript from Stripe and it automatically sets some cookies for security purposes. They are tokens and hashes that Stripe uses to calculate some signatures. These are technically required cookies but I didn't find anything about them in the app documentation: [https://developer.shopware.com/docs/guides/plugins/apps/storefront/cookies-with-apps] This guide is only for comfort cookies.

I would like to know how I can register cookies that are technically required. Also I don't know beforehand what values they will get, I do know the cookie names though. How can I add these to the cookie consent manager?


Solution

  • Simply use the existing snippet for the group of required cookies as snippet-name of your apps cookie group and the existing group's entries and your custom entries will be merged.

    <cookies>
        <group>
            <snippet-name>cookie.groupRequired</snippet-name>
            <entries>
                <cookie>
                    <cookie>my-cookie</cookie>
                    <snippet-name>example-app-with-cookies.my-cookie.name</snippet-name>
                    <snippet-description>example-app-with-cookies.my-cookie.description</snippet-description>
                    <value>a static value for the cookie</value>
                    <expiration>1</expiration>
                </cookie>
            </entries>
        </group>
    </cookies>