Adding preference buttons to main nav that persist via user sessions. (Woocommerce)

I would prefer not installing a plugin to achieve this and I don't mind coding something myself. I'm simply unsure of the wordpress-y way to go about it.

So here goes, Each one of the products has four variations, always the same, they are the region selection and the prices are different based on those.

However, I would like to have a dropdown in the main nav of the site where customers can specify what variation (region) price is displayed across the site for the whole duration of their session.

So it's a two-part thing, I would like to know the ideal method of saving this user preference in the $_SESSION (I'm assuming) and then retrieving this information when displaying prices by variation, I already have a hook to handle that in the category pages but at the moment it defaults to just a hardcoded region, instead it should be user preference OR default of america.

This information does not need to be persisted to disk or DB, it can just be in the session.

Thank you in advance, and please let me know if anything needs clarification.

/edit Just noticed the wc offtopic tag, but although yes it's somewhat related to woocommerce, storing a value in the user session isn't a wc specific thing at all. It's a user session question, wc is just framing for the use case.

Topic woocommerce-offtopic session Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.