Ok…Then the easier way is to use that identifier and save that along with the order as a post meta. Because an order in WooCommerce is a custom post type as “shop_order”. This way the order will always be tied to that unique identifier and you won’t need to deal with sessions.

Yes that’s what I was thinking – add it to wp_post meta.
My question is how to go about that. I’m not that familiar with WP, do I need to create an action? And I can’t see any examples of how to insert data into the database.

i was looking at the woocommerce_order_status_completed hook, I’m not sure how best to proceed.