Not able to find a way to set server side cookies in Shopify

6 0 1

We are developing an app for Shopify, The app should be able to set server side cookies to avoid Apple's ITP 2.1 restrictions. I see the possibility of inserting piece of javascript code to theme.liquid file or by inserting scriptTags with the logic of saving cookies. But since these are executed at frontend or on browser, the cookies set by this way are treated as client side cookies and this has limitation of only 7 days in safari browsers.

So we need to find a way in Shopify to set server side cookies. The task of the app is, in Shopify based e-commerce websites, it has to read the url from browser and capture a specific parameter if exist in url and set this as server side cookie. That means on loading of the pages, Shopify should responds with all html, javascript of the page and in addition to that it should have response headers with set-cookie: <parameter>=<value>. But I read through lot of documentations, I could not get the solution anywhere.
could you please let me know if there is a way for this?

Note:- We are developing the same app for Magento platform as well, we are able to set server side cookies there. This restriction on Shopify making us to deal with lot of architecture changes. So showing us the way is much appreciated..