function SessionTestController::set

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php \Drupal\session_test\Controller\SessionTestController::set()
  2. 8.9.x core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php \Drupal\session_test\Controller\SessionTestController::set()
  3. 10 core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php \Drupal\session_test\Controller\SessionTestController::set()

Stores a value in 'session_test_value' session attribute.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request object.

string $test_value: A session value.

1 call to SessionTestController::set()
SessionTestController::noSet in core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php
Turns off session saving and then tries to save a value anyway.
1 string reference to 'SessionTestController::set'
session_test.routing.yml in core/modules/system/tests/modules/session_test/session_test.routing.yml
core/modules/system/tests/modules/session_test/session_test.routing.yml

File

core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php, line 81

Class

SessionTestController
Controller providing page callbacks for session tests.

Namespace

Drupal\session_test\Controller

Code

public function set(Request $request, $test_value) : array {
  $request->getSession()
    ->set('session_test_value', $test_value);
  return [
    '#markup' => $this->t('The current value of the stored session variable has been set to %val', [
      '%val' => $test_value,
    ]),
  ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.