Hi,

I'm working on an access form that eventually needs to redirect to another page on my Drupal site. I created a custom module and a form. I also made a config form for the password, which Drupal sees (as well as the cookie all the way below), but I'm having issues with...

1) Creating an error message for an incorrect password.

2) Redirecting the user to my node page once the password is successfully validated.

Thanks for any help.

<?php
/**
 * @file
 * Contains \Drupal\cookie_authentication\Form\CookieForm.
 */
namespace Drupal\cookie_authentication\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class CookieForm extends FormBase {
  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'cookie_authentication';
  }
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['password'] = array(
      '#type' => 'textfield',
      '#title' => t('Access'),
      '#required' => TRUE,
     );
    
    $form['actions']['#type'] = 'actions';
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => $this->t('Submit'),
      '#button_type' => 'primary',
    );
    return $form;
  }
  /**
   * {@inheritdoc}
   */

    public function validateForm(array &$form, FormStateInterface $form_state) {
    }
    
  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $password = $form_state->getValue('password');
    setcookie("password", $password );
   }
 
}