This is possible.
Caroline (aka Super C) has a great tutorial on her blog here.
I have found it much better and less fragile to leverage the fact any shop can have Metafields associated with it, any Product can, and any Collection as well.
When you use Metafields to provide extra info about a product (sofa, chair, shoe, boat, t-shirt) you can render those attributes and collect them. You no longer need cookies, and the owner of the shop can manage the custom options with little effort.
A big bonus of this approach is no frivolous blowing of SKU's and no need for the awkward Shopify 3 variant option setup and code.
I can demonstrate how this approach is probably your best bet when you are a serious vendor with products that require more than just a few sizes and colors.
I expand it for you then... fragile is a synonym for the fact that using cookies requires you to use a LOT more code to do the same thing.
Having written twenty or more of those shops in the last 5 years, each time tweaking the cookie pattern I used, it became clear that pattern was weak, too many maintenance headaches when the client wanted one more thing added, and ultimately, I learned to do away with it. Not to mention, you get no cart or session to write cookies against in a virgin product.liquid. No one has dealt with that, it is swept under the rug.
Have you figured out how to do quantity with your code yet? Last time I checked you were not handling quantity changes. That adds yet another complex issue with cookies. I mastered that, and it bloats the cookie code to yet another level. Additionally, you only get 4K per cookie, and I have one old site that actually maxed that out, forcing me to write a multi-cookie handler. All in all, while it clearly works, I will take the solution and pattern that does the same with about half the code.
That being said, until recently even the approach of purely using cart.attributes was hampered by a bug, so no one could've done much anyway with cart.attributes, except hope the one time they were created was the only time.
You get my dig on fragile now? I guess I should've been more verbose.
@HunkyBill I see where you are coming from, and I agree that a LOT more code can lead to complexity and therefore a fragile system. As for elegance of the solution, well don't get me started... But, it gets the job done and to put things in perspective, Personified is 250-ish lines of code (not minimized & not counting dependencies). Is that a lot? Is it complex? I dunno. I can tell you it is just over three pages on my monitor. (For laughs, I ran the code through jsmeter.info, and the most complex method came in at 10 which I think is probably ok - mostly because I'm standing on the shoulders of giants.)
Personified does deal with quantities now and yes a lot of that 250 lines is dealing with that layer of complexity, but I have tried my best to hide this as much as possible/reasonable so our users will never have to see it.
BTW, I don't try to mess with the cart attributes until I'm on the cart page. You don't have to worry about carts being active in the session that way.