Updated login script

Updated login script and added session varible to monitor if a user has
tried t login. Further efforts made to organise includes and code.