Change to store log and session in mysql and auto-determine environment

Uses cloud database