Logs a user in and tracks session with a cookie.