Hacking Gmail

(Grace) #1

72 Part II — Getting Inside Gmail


Listing 5-7:Cookie-Setting Code from the Gmail Login

function SetGmailCookie(name, value) {
document.cookie = name + “=” + value +
“;path=/;domain=google.com”;
}

// This is called when the user logs in to gmail.
// We set a GMAIL_LOGIN2 cookie with the initial timings.
// The first letter “T” in the cookie value means that the
login is not
// completed yet. The main JS will complete logging the
timings and update
// the GMAIL_LOGIN2 cookie. See main.js
function lg() {
var now = (new Date()).getTime();

// use start_time as a place holder for login_box_time until
we’ve
// completely rolled out html-only login
var cookie = “T” + start_time + “/” + start_time + “/” +
now;
SetGmailCookie(“GMAIL_LOGIN2”, cookie);
}

var login_box_time;
function IframeOnLoad() {
if (!login_box_time) {
login_box_time = (new Date()).getTime();
}
}

function el(id) {
if (document.getElementById) {
return document.getElementById(id);
}
return null;
}

var ONE_PX = “https://gmail.google.com/gmail/images/c.gif?t=”
+
(new Date()).getTime();

function LogRoundtripTime() {
var img = new Image();
var start = (new Date()).getTime();
img.onload = GetRoundtripTimeFunction(start);
Free download pdf