how to pass variables from one module to another module?
As alternative, you can use also drupal_static() if the value you pass from a module to the other doesn't need to be saved past the page request. When both the modules pass to drupal_static() the same value for the first parameter, they get the same static value.

In the case you use drupal_static(), you must be sure the module that is setting the static variable is executed before the module that reads that value.