Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

The session management functions in /core/includes/session.inc have been converted into a SessionManager class, which is made available as session_manager service now.

Drupal 7

// Force-start a session.
drupal_session_start();
// Check whether a session has been started.
drupal_session_started();
// Migrate the current session from anonymous to authenticated (or vice-versa).
drupal_session_regenerate();
// Delete the session(s) of a particular user.
drupal_session_destroy_uid($uid);

Drupal 8

$session_manager = \Drupal::service('session_manager');

// Force-start a session.
$session_manager->start();
// Check whether a session has been started.
$session_manager->isStarted();
// Migrate the current session from anonymous to authenticated (or vice-versa).
$session_manager->regenerate();
// Delete the session(s) of a particular user.
$session_manager->delete($uid);

Drupal 8 post beta6

$session = \Drupal::service('session');
// Alternatively
$session = $request->getSession();

// Force-start a session.
$session->start();
// Check whether a session has been started.
$session->isStarted();
// Migrate the current session from anonymous to authenticated (or vice-versa).
$session->migrate();
Impacts: 
Module developers