I have been having this problem multiple times, and there are so many non-working solutions online. So I thought I should recorded for future usage.
Edit the following file with this content:
sudo vim /etc/lightdm/lightdm.conf
vim can be replace with whatever command-line editor you have available, nano, emac, etc…