Programmaticaly change lightdm autologin session type

In lightDM, try this.

Open (gksu gedit) the file /etc/lightdm/lightdm.conf Change the values (in # Seat configuration) from:

#default-user=bob
#default-user-timeout=5
#pam-service=lightdm

to:

default-user=username
default-user-timeout=0
pam-service=lightdm-autologin

And you can do this to: Edit /etc/gdm/custom.conf file.

[daemon]
TimedLoginEnable=false
AutomaticLoginEnable=true
TimedLogin=(your username)
AutomaticLogin=(your username)
TimedLoginDelay=0
DefaultSession=gnome

Finally reboot it, This will automatically login your username.