Cookie Consent Storing

  • Navigate to Cloudflare’s official website by clicking on the following link:
    https://www.cloudflare.com/
  • If you already have a Cloudflare account, simply log in.
  • If you don't have an account, click on "Start for Free" as shown in the image below to create a new account.

Cookie Consent Storing — screenshot 1

  • You can easily sign up for a Cloudflare account using your Google or Apple account for a faster registration process.

Cookie Consent Storing — screenshot 2

  • After a successful login, you will be redirected to the Cloudflare dashboard. In the left sidebar menu, find Compute , click on it to expand the options, and then select Workers & Pages.

Cookie Consent Storing — screenshot 3

  • Then, click "Create application" to add a new worker.

Cookie Consent Storing — screenshot 4

  • Then select a method "start with Hello World"

Cookie Consent Storing — screenshot 5

  • Give your worker a name and click Deploy. In our example, we have named the worker cookie-consent-flowappz.

Cookie Consent Storing — screenshot 6

  • You will be redirected to the Success page. Click Edit Code to proceed.

Cookie Consent Storing — screenshot 7

  • Then, paste the following code into the code editor and click Deploy.
export default{async fetch(e,s){const t={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, HEAD, POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type","Access-Control-Allow-Credentials":"true","Access-Control-Max-Age":"86400"};if("OPTIONS"===e.method)return new Response(null,{headers:t});if("POST"===e.method)try{const o=await e.json(),{cookiePreferences:r,expiryDate:n,browserInfo:a,userIp:c,action:l}=o;if(!(r&&n&&a&&c&&l))return new Response("Invalid payload: Missing required fields.",{status:400,headers:t});const i={action:l,userIp:c,browserInfo:a,cookiePreferences:r,expiryDate:n,timestamp:(new Date).toISOString()};return await s.CONSENTS.put(c,JSON.stringify(i)),new Response("Consent preferences successfully stored.",{status:200,headers:t})}catch(e){return console.error("Failed to store data in KV:",e),new Response("Failed to store consent preferences.",{status:500,headers:t})}return new Response("Method Not Allowed",{status:405,headers:t})}};

Cookie Consent Storing — screenshot 8

  • Then, go back to the Dashboard, and in the left-side menu under Storage and Databases, click on Workers KV.

Cookie Consent Storing — screenshot 9

  • Then, click on Create Instance.

Cookie Consent Storing — screenshot 10

  • Give a name to the Namespace and click Create. In our example, we have used the name Cookie Consent KV.

Cookie Consent Storing — screenshot 11

  • Go to Workers and Pages, then click on the previously created worker. In our example, it is cookie-consent-flowappz.

Cookie Consent Storing — screenshot 12

  • Navigate to the Bindings tab and click on Add Binding

Cookie Consent Storing — screenshot 13

  • Then, select the KV Namespace then click Add binding.

Cookie Consent Storing — screenshot 14

  • Enter the variable name as CONSENTS and select the KV namespace as Cookie Consent KV. After that, click Add Binging.

Cookie Consent Storing — screenshot 15

  • Right-click on the icon shown in the image and copy the URL.

Cookie Consent Storing — screenshot 16

  • Open your cookie consent app in the designer. Navigate to the Settings tab, paste the URL into the Consent Storing Endpoint input field, and then click Save Settings.

Cookie Consent Storing — screenshot 17

  • To view all stored consents, navigate to KV under Storage and Databases, then click on Cookie Consent KV.

Cookie Consent Storing — screenshot 18

  • Then, navigate to the KV Pairs section, where you will see all the users' consents.

Cookie Consent Storing — screenshot 19

Was this page helpful?

Thanks — that's logged. If something here is wrong or missing, tell us what you needed.

Last updated August 8, 2026