I think a programmatic approach to this is going to be unnecessarily complicated.
How about a browser plugin instead? http://www.ghacks.net/2007/10/15/use-autologin-in-firefox/
Or LastPass
solved Auto fill the values in login form of another website [duplicate]