Display/hide CCk field with custom PHP and rules or I have custom variables stored in sessions, those variables are obtained remotely via URL arguments fired by remote website. 

I am currently using Drupal 7, and I want to enable custom custom field A or B based on the value of the custom variable; if the custom variable is empty, it should enable field A, otherwise, enable field, B.

Can you please assist on what needs to be done?
Two quick ways come to mind.

Off the cuff...

You could use the preprocess_node() hook, something along the lines of:

MYMODULE_preprocess_node(&amp;$variables) {

  if ($variables['node']-&gt;type=='THISKINDOFNODE') {

    if (empty($_SESSION['VARIABLE')) {
      unset($variables['node']-&gt;field_B;
    } else {
      unset($variables['node']-&gt;field_A;
    }

  }

  // other preprocessing here

}


You also could create a node--TYPE.tpl.php file and inside it, do something like this:

if (empty($_SESSION['VARIABLE'])) {
  hide($content['field_B');
} else {
  hide($content['field_A');
}