Grab URL parameter and pass it into $session .. what is the best way?

Hello dear peoples,

Do you have an opinion how to best handle this trick?
I want to grab an URL parameter from an incoming link and pass it to the $session to make it available when the user visits a certain page.

I did play around with the Middleware but it seems so bloated and unnecessary big that I feel to be on the wrong path. What would you suggest or how did you do it?

Thanks for any hints!

Or… would you pass it to cookie instead? I want to track the purchases in a store…

This documentation has some good information about working with Sessions in Concrete - Session handling and GDPR :: Concrete CMS