349Chapter 18 .The Document and Body Objects Other (Web hosting colocation)

349Chapter 18 .The Document and Body Objects Other applications of the cookie include storing user preferences and information about the user s previous visit to the site. Preferences may include font styles or sizes and whether the user prefers viewing content inside a frameset or not. As shown in Chapter 54, a time stamp of the previous visit can allow a coded HTML page to display highlighted images next to content that has changed since the user s last visit, even if you have updated the page several times in the interim. Rather than hard-wiring New flags for your last visit, the scripts highlight what s new for the visitor. Note I cover the technical differences between Navigator and Internet Explorer cookies later in this section. But for IE3, be aware that the browser neither reads nor writes cookies when the document accessing the cookie is on the local hard disk. IE4+ works with cookies generated by local files. The cookie file Allowing some foreign CGI program to read from and write to your hard disk may give you pause, but browser cookie mechanisms don t just open up your drive s directory for the world to see (or corrupt). Instead, the cookie mechanism provides access to just one special text file (Navigator) or type of text file (Internet Explorer) located in a platform-specific spot on your drive. In Windows versions of Navigator 4, for example, the cookie file is named cookies.txt and is located in a directory reserved for a user s Navigator preferences; Mac users can find the MagicCookiefile inside the Netscape folder, which is located within the System Folder:Preferences folder. Internet Explorer for Windows uses a different filing system: all cookies for each domain saved in a domain-specific file inside a Cookies directory within system directories. File names include the user name and domain of the server that wrote the cookie. A cookie file is a text file (but because NN s Macintosh MagicCookie file s type is not TEXT, Mac users can open it only via applications capable of opening any kind of file). If curiosity drives you to open a cookie file, I recommend you do so only with a copy saved in another directory or folder. Any alteration to the existing file can mess up whatever valuable cookies are stored there for sites you regularly visit. The data format for NN and IE differs, in line with the different methodologies used for filing cookies. Inside the Netscape file (after a few comment lines warning you not to manually alter the file) are lines of tab-delimited text. Each return-delimited line contains one cookie s information. The cookie file is just like a text listing of a database. In each of the IE cookie files, the same data points are stored for a cookie as for Navigator, but the items are in a return-delimited list. The structure of these files is of no importance to scripting cookies, because both browsers utilize the same syntax for reading and writing cookies through the document.cookieproperty. Note As you experiment with browser s cookies, you will be tempted to look into the cookie file after a script writes some data to the cookie. The cookie file will not contain the newly written data, because cookies are transferred to disk only when the user quits the browser; conversely, the cookie file is read into the browser s memory when it is launched. While you read, write, and delete cookies during a browser session, all activity is performed in memory (to speed up the process) to be saved later. document.cookie
You want to have a cheap webhost for your apache application, then check apache web hosting services.

Leave a Reply