function SessionTestController::set

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

Stores a value in $_SESSION['session_test_value'].

Parameters

string $test_value: A session value.

Return value

string A notification message.

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 85

Class

SessionTestController
Controller providing page callbacks for the action admin interface.

Namespace

Drupal\session_test\Controller

Code

public function set($test_value) {
    $_SESSION['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.