Sessions refactored with flash support. Insert/Update query added