materio expo use now cookie instead of session

This commit is contained in:
2021-09-09 16:14:11 +02:00
parent 2ffda1e0b2
commit 277f3cb445
3 changed files with 33 additions and 18 deletions

View File

@@ -4,7 +4,6 @@ namespace Drupal\materio_expo\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
// use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -52,8 +51,9 @@ class GetEmail extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state, $ref = null) {
// check if email cookie is already present
$session = \Drupal::request()->getSession();
$alreadysetemail = $session->get('materio_expo_email');
// $session = \Drupal::request()->getSession();
// $alreadysetemail = $session->get('materio_expo_email');
$alreadysetemail = \Drupal::request()->cookies->get('materio_expo_email', false);
if($alreadysetemail){
// https://x-team.com/blog/drupal-goto/
$url = Url::fromRoute('materio_expo.qr_controller_getfile', ['ref'=>$ref], ['absolute' => TRUE]);
@@ -145,7 +145,7 @@ class GetEmail extends FormBase {
//* redirect to getfile controller
$ref = $values['ref'];
$form_state->setRedirect('materio_expo.qr_controller_getfile', ['ref'=>$ref]);
$form_state->setRedirect('materio_expo.qr_controller_setcookie', ['ref'=>$ref]);
}