What's the best way to build a referral attribution system with "cookie" period? How long do local storage variables in Weweb last, would that be enough?

Trying to create a referral program in Weweb.

What’s the best way to build a referral attribution system? For instance, use URL query param with referrer ID, then set a local variable with that ID so that if that user comes back to sign up, I can read the local variable to see who originally referred them?

Is there an expiry time for local variables? Can I set that somewhere?

OR is it better to “set a cookie”, what’s the difference? And how do I set this?

Basically, I have the same question as this thread here:

It entirely depends on the user.

Looks like I need the cookie expiry time so it’s cookies, does anyone have any idea how to “set a cookie” from a refID in the URL?

And then how do I get this “cookie” to talk to variables in Weweb?

Would require some js, this and copilot might help