Get the form ID from a Webform entity
Rather than storing the form ID, you could just store the webform ID and check that in a form alter. Webform provides its own form alter hook that only fires for webforms and lets you put the hook in a dedicated include file.

See honeypot_webform_submission_form_alter() in third_party_settings/webform.honeypot.inc for an example of getting the webform from the hook:

/**
 * Implements hook_webform_submission_form_alter().
 */
function honeypot_webform_submission_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {
  // &lt;snip&gt;

  /** @var \Drupal\webform\WebformSubmissionInterface $webform_submission */
  $webform_submission = $form_state-&gt;getFormObject()-&gt;getEntity();
  $webform = $webform_submission-&gt;getWebform();


From there you can use $webform-&gt;id() to get the webform ID.