Add a custom way to store sessions and fix store sessions in DB - refs BT#8340