Main Page


Traditionally, JavaScript had no interaction with the server at all; it merely performed operations
on the client and then got out of the way to allow the server to do its job. As the Web progressed,
however, JavaScript was required to send data back to the server and/or receive a response. This
need led to several methods of establishing such communication.
Despite reports in newspapers and magazines citing security issues, a cookie is nothing more than
a small amount of information that a Web page places on a user ’s machine. Cookies have tradi-
tionally been used to store login information so that users aren’t required to log in each time they
access a restricted page from the same machine (the ubiquitous Remember Me check box on many
login pages).
Because a cookie is unique to a user, Web sites can determine when a user has returned to the site,
as well as what pages he visits; this is where the privacy concerns arise. Yes, a cookie can be used
to track where you go on an individual Web site, but it cannot be used to grab personal informa-
tion (such as credit card numbers, e-mail addresses, and so on), as many novices think.
Cookies were the first method of client-server interaction that JavaScript took advantage of. Every
time the browser makes a request to a server, the cookies for that server are sent along with any
other information. This enables JavaScript to set a cookie on the client that a server can read later.
19_579088 ch16.qxd 3/28/05 11:42 AM Page 481

JavaScript EditorFree JavaScript Editor     Ajax Editor