10.07.2015 Views

Beginning Web Development With Perl : From Novice to ... - Nabo

Beginning Web Development With Perl : From Novice to ... - Nabo

Beginning Web Development With Perl : From Novice to ... - Nabo

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 1 ■ THE CGI MODULE 15Update your code on the web server with this new code. Don’t forget <strong>to</strong> click the refreshbut<strong>to</strong>n in your web browser <strong>to</strong> ensure that you have the new code within your version of thepage. If you fail <strong>to</strong> reload the page after saving the new code, you won’t get the same results asthe rest of us.Now you can fill in your name and click the Submit Query but<strong>to</strong>n. If your name is Steve,you’ll see the output shown in Figure 1-4.Figure 1-4. Printing the name based on what was submittedCookiesCookies are <strong>to</strong>kens or data sent in the HTTP header. Cookies sometimes reside in volatilememory for the duration of the browser setting and can also be saved as persistent text fileson the user’s computer. You can use cookies for many reasons, including carrying informationabout users <strong>to</strong> enhance their browsing experience. Cookies offer a very useful way <strong>to</strong> maintainstate between visits or during a session.■Caution Cookies are often overused and relied upon unnecessarily. Additionally, some users overestimatethe risks of allowing cookies and misunderstand the privacy concerns related <strong>to</strong> their use. For these reasons,some users will disable cookies in their browsers. Therefore, you shouldn’t design an application that relieson cookies for session state or other client-side settings.The CGI module includes powerful functions <strong>to</strong> assist in creating and managing browsercookies. Here, I’ll show you some examples. But first, let’s see what goes in<strong>to</strong> a cookie. (I find itdifficult <strong>to</strong> resist clever but overdone metaphors when writing about cookies; therefore, I’llapologize in advance for some of the titles of the forthcoming sections.)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!