Added login function.

Not fully tested yet so there is a lack of a logout option.