title: PHP session_set_save_handler not saving to database
body: <p>I created a class to save the session data to a database. it is not saving to the database and there are no errors. Any idea why? here is the class.</p>
  
  <pre><code> &lt;?php
  
  class Session {
  
  
  public function __construct(){
      //set handle to override SESSION
      $session_id = session_id();
      $session_name = session_name();
      $session_path = session_save_path();
      echo "in class";
  }
  
  function open(){
      include("includes/globals.php");
      global $_sess_db;
  echo "in open";
      if(mysql_connect('127.0.0.1','root','') or die(mysql_error())){
          return mysql_select_db($CallPro_dbname, $_sess_db);
          echo "connected";
      }
      return FALSE;
  }
  
  function close(){
      global $_sess_db;
      return mysql_close($_sess_db);
  }
  
  function read($session_id){
      mysql_connect('127.0.0.1','root','');
              $record;
      $sql = "select * from callprodev.session_data where agentid = '".$_SESSION['agentid']."'";
      $result = mysql_query($sql,$_sess_db)or die(mysql_error());
      $record = mysql_fetch_assoc($result)or die(mysql_error());
      echo "read";
  
  }
  function write($session_id){
      mysql_connect('127.0.0.1','root','');
              $access = time();
      $access = mysql_real_escape_string($access);
      $sql = "REPLACE
      INTO    callprodev.session_data
      VALUES  (
      '{$_SESSION['agentid']}',
      '{$_SESSION['extension']}',
      '{$_SESSION['page']}',
      '{$_SESSION['vduser']}',
      '{$_SESSION['vdpass']}',
      '{$_SESSION['action_main_plugin']}',
      '{$_SESSION['caller_phone']}',
      '{$_SESSION['campaignid']}',
      '{$_SESSION['uniqueid']}',
      '{$_SESSION['dialed']}',
      '{$_SESSION['rurl']}',
      '{$_SESSION['reference_id']}',
      '{$_SESSION['contactid']}',
      '{$_SESSION['groupid']}',
      '{$_SESSION['script_info_plugin']}',
      '{$_SESSION['flags']}',
      '{$_SESSION['dispositioned']}'
      )";
      echo "write";
      return mysql_query($sql, $_sess_db)or die(mysql_error());
  }
  function destroy($session_id){
      mysql_connect('127.0.0.1','root','');
              $sql = "delete from callprodev.session_data where id = '{$_SESSION['agentid']}'";
              echo "destroy";
      return mysql_query($sql, $_sess_db)or die(mysql_error());
  }
  function gc($max){
  
  }
  
  }
  
  $session_record = new Session();
  
  session_set_save_handler(
      array($session_record, "open"),
      array($session_record, "close"),
      array($session_record, "read"),
      array($session_record, "write"),
      array($session_record, "destroy"),
      array($session_record, "gc"));
  
  register_shutdown_function('session_write_close');
  
  
  session_start();
  </code></pre>
  
  <p>The session is included in an init.php file. it is called like this.</p>
  
  <pre><code>include("classes/Session.php");
  
  
  $session_record                     = new Session();
  
  session_set_save_handler(
      array($session_record, "open"),
      array($session_record, "close"),
      array($session_record, "read"),
      array($session_record, "write"),
      array($session_record, "destroy"),
      array($session_record, "gc"));
  
  session_start();
  </code></pre>