Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294726

Objectify session management functions + remove session.inc

$
0
0

Objective

  1. #2205295: Objectify session handler converted Drupal's internal session handling functions into a PHP 5.4 SessionHandler class.

  2. The remainder of session.inc are high-level, public API functions to manage user sessions.

Proposed resolution

  1. Convert the procedural session management functions into a new SessionManager service.

    Note: The functionality of this service/class is named SessionStorage in Symfony (which is a complete misnomer).

  2. Properly inject the session_manager dependency into other services:

    • Cookie authentication provider
    • Cron
  3. Remove /core/includes/session.inc.

API changes

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

<?php
// 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

<?php
$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);
?>

Viewing all articles
Browse latest Browse all 294726

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>