You are here

function hybridauth_session_start in HybridAuth Social Login 7.2

Initialize the user session before using the HybridAuth library.

2 calls to hybridauth_session_start()
hybridauth_endpoint in ./hybridauth.pages.inc
@file HybridAuth module pages.
hybridauth_window_start in ./hybridauth.pages.inc

File

./hybridauth.pages.inc, line 31
HybridAuth module pages.

Code

function hybridauth_session_start() {

  // Make sure that a user session exists.
  drupal_session_start();

  // Special handling for HTTPS with normal session IDs and secure session IDs.
  // Duplicated sessions are created, so we need to pull out the correct session
  // data.
  global $is_https;
  if ($is_https && variable_get('https', FALSE)) {

    // If there is an existing session with the same secure session ID we need
    // to replace the $_SESSION contents with that.
    $session = db_query('SELECT session FROM {sessions} WHERE sid = :sid AND ssid = :sid', array(
      'sid' => session_id(),
    ))
      ->fetchField();
    if ($session) {

      // Overwrite $_SESSION with the data.
      session_decode($session);

      // Remove the duplicate session from the database.
      db_delete('sessions')
        ->condition('sid', session_id())
        ->execute();
    }
  }
}