Implemented the session->write() DAO method to support an upsert on MySQL and a two-phase insert/update on Pgsql.

We saw some errors with the code when running on NFS, since Piwik uses database-backed sessions in that scenario. We determined the problem was due to missing DAO support for writing session data.

We could have tried the insert on Pgsql and trapped the unique constraint violation. But in this case querying for the session first might be more efficient, since it's a simple primary key lookup, and exceptions are expensive. Granted, this approach isn't thread-safe, but that shouldn't be a major issue.