function SessionTestController::getId

Print the current session ID.

Parameters

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

1 string reference to 'SessionTestController::getId'
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 50

Class

SessionTestController
Controller providing page callbacks for session tests.

Namespace

Drupal\session_test\Controller

Code

public function getId(Request $request) : array {
  // Set a value in session, so that SessionManager::save() will start
  // a session.
  $session = $request->getSession();
  $session->set('test', 'test');
  $session->save();
  return [
    '#markup' => 'session_id:' . session_id() . "\n",
  ];
}

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