Basic login system.

This requires activating the DB. It's also imperfect for iPhone webapps
because those do not appear to store cookies.
Fix typo in event name

The typo doesn't appear to have actually broken anything, so that's a
little odd.
Ensure the session cookie can be accessed by javascript

We'll need access to enable some a filthy hack to work around the lack
of persistent cookies for iPhone webapps.
Store the session ID in the localStorage object.

When we find ourselves logged out first try to re-set the session
cookie in the hope that the session will still be valid, so we don't
need to log in manually.