You are here

public function SessionTestController::getIdFromCookie in Drupal 8

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::getIdFromCookie()

Print the current session ID as read from the cookie.

Parameters

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

Return value

string A notification message with session ID.

1 string reference to 'SessionTestController::getIdFromCookie'
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 72

Class

SessionTestController
Controller providing page callbacks for the action admin interface.

Namespace

Drupal\session_test\Controller

Code

public function getIdFromCookie(Request $request) {
  return [
    '#markup' => 'session_id:' . $request->cookies
      ->get(session_name()) . "\n",
    '#cache' => [
      'contexts' => [
        'cookies:' . session_name(),
      ],
    ],
  ];
}