You are here

public function SessionProxy_Backend_Base::__construct in Session Proxy 7

Default constructor.

1 call to SessionProxy_Backend_Base::__construct()
SessionProxy_Backend_Default::__construct in lib/SessionProxy/Backend/Default.php
Default constructor.
1 method overrides SessionProxy_Backend_Base::__construct()
SessionProxy_Backend_Default::__construct in lib/SessionProxy/Backend/Default.php
Default constructor.

File

lib/SessionProxy/Backend/Base.php, line 204

Class

SessionProxy_Backend_Base

Code

public function __construct() {
  global $user, $is_https;
  $this->httpsEnabled = $this
    ->handleHttps() && $is_https;
  $this->sessionName = session_name();
  if ($this->httpsEnabled) {
    $this->sessionNameUnsecure = substr(session_name(), 1);
  }
  if (!empty($_COOKIE[$this->sessionName]) || $this->httpsEnabled && !empty($_COOKIE[$this->sessionNameUnsecure])) {

    // If a session cookie exists, initialize the session. Otherwise the
    // session is only started on demand in drupal_session_commit(), making
    // anonymous users not use a session cookie unless something is stored in
    // $_SESSION. This allows HTTP proxies to cache anonymous page views.
    $this
      ->start();
    $this->sessionIdentifier = session_id();
    $this
      ->refreshAfterSessionChange();
    if ($user->uid || !$this
      ->sessionIsEmpty()) {
      drupal_page_is_cacheable(FALSE);
    }
  }
  else {

    // Set a session identifier for this request. This is necessary because
    // we lazily start sessions at the end of this request, and some
    // processes (like drupal_get_token()) needs to know the future
    // session ID in advance.
    $user = drupal_anonymous_user();
    $this
      ->generateSessionIdentifier();
    $this
      ->refreshAfterSessionChange();
  }
}