Store user history in db