thomascube
2011-03-22 ec045b0a24bbb0de2b203961b453a9f5bd640f34
program/include/rcube_session.php
@@ -192,6 +192,19 @@
  /**
   * Cleanup session data before saving
   */
  public function cleanup()
  {
    // current compose information is stored in $_SESSION['compose'], move it to $_SESSION['compose_data']
    if ($_SESSION['compose']) {
      $_SESSION['compose_data'][$_SESSION['compose']['id']] = $_SESSION['compose'];
      $this->remove('compose');
    }
  }
  /**
   * Register additional garbage collector functions
   *
   * @param mixed Callback function
@@ -205,27 +218,15 @@
  /**
   * Generate and set new session id
   *
   * @param boolean $destroy If enabled the current session will be destroyed
   */
  public function regenerate_id()
  public function regenerate_id($destroy=true)
  {
    // delete old session record
    $this->destroy(session_id());
    session_regenerate_id($destroy);
    $this->vars = false;
    $randval = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    for ($random = '', $i=1; $i <= 32; $i++) {
      $random .= substr($randval, mt_rand(0,(strlen($randval) - 1)), 1);
    }
    // use md5 value for id
    $this->key = md5($random);
    session_id($this->key);
    $cookie   = session_get_cookie_params();
    $lifetime = $cookie['lifetime'] ? time() + $cookie['lifetime'] : 0;
    rcmail::setcookie(session_name(), $this->key, $lifetime);
    $this->key  = session_id();
    return true;
  }
@@ -253,6 +254,7 @@
   */
  public function kill()
  {
    $this->vars = false;
    $this->destroy(session_id());
    rcmail::setcookie($this->cookiename, '-del-', time() - 60);
  }