I have two hooks in separate HTML request.
I have to pass some data i.e. variable from one to the other.
What is the most practical and transparent method for it?
It's not possible to pass data from one HTTP request to another one on the fly. Once the script is finished, the data will be discarded.
What you can do is to store the data in a transient, and then retrieve it later. Here's a simple example using
set_transient( 'my_transient', $data, 1 * HOUR_IN_SECONDS );
Then, you can retrieve it using
get_transient( 'my_transient' );
in the very general case, you just can not. Two http requests are fully independent from each other, and in case of big site might not even be processed by the same server.
What you need to do is to "force" the second request to carry information that will help you identify or extract the relevant values when processing it.
The most basic mechanism for that is cookies, but that is not the only one, and if for example you handle multi page form, you can simply include it as hidden input in the next form page you generate, and if the whole thing is done via AJAX, you can add state information in a reply to the first request, store it in some global space, and attach it to the next request.