url_to_postid(wp_get_referer()) will give you the ID of the referring page/post if you were referred from a page or a post. It won't work if referred from some other types of pages, like archives.
You will then need to retrieve the categories for the ID to see if they match.
I would strongly consider passing a parameter with the request though. You should already have the post ID and possibly the post data on the referring page and won't have to make separate queries to grab it.
You can use a
nonce to help prevent abuse of the parameter-- that is, to prevent someone from just typing
?status=free into the URL.
You mention sessions in a comment. I have used sessions successfully in WordPress and with little trouble. Be aware that a lot of people complain about sessions with WordPress.