title: Kohana won't read session data in database
body: <p>a few minutes ago i deployed a new version of my application to stage instances. After trying to login i have following error:</p>
  
  <pre><code>Session_Exception [ 1 ]: Error reading session data. [Details: Database_Exception [ ]: ~ MODPATH/database/classes/Kohana/Database/MySQL.php [ 108 ] ]
  </code></pre>
  
  <p>Stackoverflow is full of these errors, but no possible answer helped me.</p>
  
  <p>My database config file:</p>
  
  <pre><code> &lt;?php defined('SYSPATH') OR die('No direct access allowed.');
  
  return array
  (
  'default' =&gt; array
  (
      'type'       =&gt; 'MySQL',
      'connection' =&gt; array(
          /**
           * The following options are available for MySQL:
           *
           * string   hostname     server hostname, or socket
           * string   database     database name
           * string   username     database username
           * string   password     database password
           * boolean  persistent   use persistent connections?
           * array    variables    system variables as "key =&gt; value" pairs
           *
           * Ports and sockets may be appended to the hostname.
           */
          'hostname'   =&gt; '127.0.0.1',
          'database'   =&gt; 'MY_DATABASE',
          'username'   =&gt; 'MY_USER',
          'password'   =&gt; 'MY_PASS',
          'persistent' =&gt; FALSE,
      ),
      'table_prefix' =&gt; '',
      'charset'      =&gt; 'utf8',
      'caching'      =&gt; FALSE,
  ),
  'alternate' =&gt; array(
      'type'       =&gt; 'PDO',
      'connection' =&gt; array(
          /**
           * The following options are available for PDO:
           *
           * string   dsn         Data Source Name
           * string   username    database username
           * string   password    database password
           * boolean  persistent  use persistent connections?
           */
          'dsn'        =&gt; 'mysql:host=localhost;dbname=kohana',
          'username'   =&gt; 'root',
          'password'   =&gt; 'r00tdb',
          'persistent' =&gt; FALSE,
      ),
      /**
       * The following extra options are available for PDO:
       *
       * string   identifier  set the escaping identifier
       */
      'table_prefix' =&gt; '',
      'charset'      =&gt; 'utf8',
      'caching'      =&gt; FALSE,
  ),
  );
  </code></pre>
  
  <p>Already tried to change hostname to <code>localhost</code> - no effect. Everything else looks fine.
  The database connection must be correct, because i have a new entry in my session table (so the user is able to read &amp; write new tuples into the session table).</p>
  
  <p>The application use session setter / getter. When the application calls the session getter, the getter try to set a new instance:</p>
  
  <pre><code>/**
   * Session Getter
   * @return tye
   */
  public static function getSession($key = null) {
      // Check, if session is given
      if (!isset($_SESSION)) {
          self::$_session = Session::instance();
      }
  
      if (!empty($key)) {
          return self::$_session-&gt;get($key);
      }
      return self::$_session;
  }
  </code></pre>
  
  <p><code>Session::instance()</code> execute the following code in <code>SYSPATH/classes/Kohana/Session.php [ 54 ] » Kohana_Session_Database-&gt;__construct(arguments)</code></p>
  
  <pre><code> //  Create a new session instance
   Session::$instances[$type] = $session = new $class($config, $id);
  </code></pre>
  
  <p>Argument Dump <code>$config</code>:</p>
  
  <pre><code>array(4) (
  "group" =&gt; string(7) "default"
  "table" =&gt; string(8) "sessions"
  "gc" =&gt; integer 500
  "columns" =&gt; array(3) (
      "session_id" =&gt; string(10) "session_id"
      "last_active" =&gt; string(11) "last_active"
      "contents" =&gt; string(8) "contents"
  )
  ) 
  </code></pre>
  
  <p>Argument Dump <code>$id</code>:</p>
  
  <pre><code>NULL
  </code></pre>
  
  <p>Following function produce the error (never modified!):</p>
  
  <pre><code>    /**
       * Select the database
       *
       * @param   string  $database Database
       * @return  void
       */
      protected function _select_db($database)
      {
              if ( ! mysql_select_db($database, $this-&gt;_connection))
              {
                      // Unable to select database
                      throw new Database_Exception(':error',
                              array(':error' =&gt; mysql_error($this-&gt;_connection)),
                              mysql_errno($this-&gt;_connection));
              }
  
              Database_MySQL::$_current_databases[$this-&gt;_connection_id] = $database;
      }
  </code></pre>
  
  <p>The application is working fine on my local system. So i think it's might be an error in php.ini. That's why i tried to set the following by <code>ini_set</code> in my index.php</p>
  
  <pre><code>    ini_set('session.auto_start', 0);
  </code></pre>
  
  <p>Without any success.. </p>