I'm currently porting SimpleFBConnect module to Drupal 8. This module uses Facebook PHP SDK which expects that we have established a session before the user is redirected to Facebook for authentication.
By reading SessionManager API, I assumed that SessionManager::start would start the session. However, this does not seem to be the case. The same thing applies to SessionManager::save (description says that this function will "Force the session to be saved and closed.").
The only way how I was able to force a session start was to call SessionManager::regenerate
.
Is this the correct way to force session start in Drupal 8?
Debug code, which will show that SessionManager::start will not start the session.
class TestController extends ControllerBase {
public function test() {
$session_manager = Drupal::service('session_manager');
$session_manager->start();
if ($session_manager->isStarted()) {
$msg = 'Sesssion started';
}
else {
$msg = 'Sesssion not started';
}
return array(
'#markup' => $msg
);
}
}