Creates a new session with the given $id and $data
string $id:
string $data:
boolean True.
private function createNewSession($id, $data = '') {
// get table/column
$dbTable = $this->dbOptions['db_table'];
$dbDataCol = $this->dbOptions['db_data_col'];
$dbIdCol = $this->dbOptions['db_id_col'];
$dbTimeCol = $this->dbOptions['db_time_col'];
$sql = "INSERT INTO {$dbTable} ({$dbIdCol}, {$dbDataCol}, {$dbTimeCol}) VALUES (:id, :data, :time)";
//session data can contain non binary safe characters so we need to encode it
$encoded = base64_encode($data);
$stmt = $this->pdo
->prepare($sql);
$stmt
->bindParam(':id', $id, \PDO::PARAM_STR);
$stmt
->bindParam(':data', $encoded, \PDO::PARAM_STR);
$stmt
->bindValue(':time', time(), \PDO::PARAM_INT);
$stmt
->execute();
return true;
}