Fix session database error handling

Signed-off-by: Kenji Suzuki <kenji.uui@gmail.com>
Merge pull request #1709 from kenjis/fix_session

Fix session database error handling