Chapter 5 — How Gmail Works 71
Viewing source on this page shows you two important things. First, there is the
username and password form itself and second some JavaScript that sets a cookie.
Deal with the form first. Listing 5-6 gives a cleaned-up version of the code, with
the styling removed.
Listing 5-6: The Gmail Login Form
<form action=”ServiceLoginAuth” id=”gaia_loginform”
method=”post”>
<input type=”hidden” name=”continue”
value=”http://gmail.google.com/gmail”>
Username:
Password: <input type=”password” name=”Passwd”
autocomplete=”off” size=”18”>
Don’t ask for my password for 2 weeks.
<input type=”submit” name=”null” value=”Sign in”>
From this we can see that the URL the page POSTs towards to log in is produced
as follows, split here for clarity.
https://www.google.com/accounts/ServiceLoginBoxAuth/continue=h
ttps://gmail.google.com/gmail
&service=mail
&Email=XXXXX
&Passwd=XXXXX
&PersistentCookie=yes
&null=Sign%20in
You will need this later on, but now, the cookie setting.
The First Cookie
The relevant sections of the JavaScript listing inside the login page appear in
Listing 5-7.