You are here

Native.php in Session Proxy 7

File

lib/SessionProxy/Backend/Native.php
View source
<?php

/**
 * Native implementation of session backend: use PHP native session handling.
 * Using it allows to use built-in extensions session handling, such as Redis
 * or Memcache extensions features, which are known to be really fast.
 */
class SessionProxy_Backend_Native extends SessionProxy_Backend_Base {
  protected function getSessionUid() {
    return isset($_SESSION['uid']) ? $_SESSION['uid'] : NULL;
  }
  public function writeDisable() {
  }
  public function writeEnable() {
  }
  public function isWriteEnabled() {
    return TRUE;
  }
  public function regenerate() {
    global $user;
    if (!$this
      ->sessionIsEmpty()) {
      $currentData = $_SESSION;
    }
    if ($this->started) {
      $this
        ->destroy();
    }
    $this
      ->generateSessionIdentifier();
    if (isset($currentData) && !empty($currentData)) {
      $_SESSION = $currentData;
      $this
        ->start();
      if ($user->uid) {
        $_SESSION['uid'] = $user->uid;
      }
    }
    else {
      if ($user->uid) {
        $this
          ->start();
        $_SESSION['uid'] = $user->uid;
      }
    }
    if ($this->started) {

      // Some PHP versions won't reset correctly the cookie.
      $params = session_get_cookie_params();
      $expire = $params['lifetime'] ? REQUEST_TIME + $params['lifetime'] : 0;
      setcookie($this->sessionName, $this->sessionIdentifier, $expire, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
    }
    $this
      ->refreshAfterSessionChange();
  }
  public function destroyAllForUser($uid) {
    return;
  }

}

Classes

Namesort descending Description
SessionProxy_Backend_Native Native implementation of session backend: use PHP native session handling. Using it allows to use built-in extensions session handling, such as Redis or Memcache extensions features, which are known to be really fast.