I don't think the user giving the answer in that post fully understood the context of the question. Shopify Scripts run on the back end of Shopify servers so they definitely won't have access to anything like a cookie, which exists only in the client's browser.
You could achieve something along these lines by:
(2) On the backend, have your Shopify scripts read that line item property and perform custom behaviour based on that.
The standard approach to "hide" line item properties is to prefix them with an underscore (eg "_cookie"), then update your theme and email templates to avoid showing customers these values.