function drupal_session_start

7.x session.inc drupal_session_start()

Starts a session forcefully, preserving already set session data.

Related topics

4 calls to drupal_session_start()
drupal_session_commit in drupal-7.x/includes/session.inc
Commits the current session, if necessary.
drupal_session_initialize in drupal-7.x/includes/session.inc
Initializes the session handler, starting a session if needed.
drupal_session_regenerate in drupal-7.x/includes/session.inc
Called when an anonymous user becomes authenticated or vice-versa.
update.php in drupal-7.x/update.php
Administrative page for handling updates from one Drupal version to another.

File

drupal-7.x/includes/session.inc, line 281
User session handling functions.

Code

function drupal_session_start() {
  // Command line clients do not support cookies nor sessions.
  if (!drupal_session_started() && !drupal_is_cli()) {
    // Save current session data before starting it, as PHP will destroy it.
    $session_data = isset($_SESSION) ? $_SESSION : NULL;

    session_start();
    drupal_session_started(TRUE);

    // Restore session data.
    if (!empty($session_data)) {
      $_SESSION += $session_data;
    }
  }
}