Set Perl Cookie - Quiz Explanation
The answers you selected are indicated below, along with text that explains the correct answers.
1.
What are the benefits of a cookie?
Please select the best answer.
A.
It saves persistent-state information to the host
B.
It identifies all hidden fields in Netscape
C.
It edits the program and fills in the variables
D.
It sends headers back and forth over the HTTP connection
The correct answer is D.
The benefit of a cookie is that it sends headers back and forth over the HTTP connection. A is incorrect because it refers to information saved to the client, not the host. B is incorrect because although hidden fields are useful for maintaining the state of a session, they do not allow users to return to a site a later time. C is incorrect because cookies do not edit nor fill in variables.
2.
Which one of the following types of cookies differs from Netscape cookies?
Please select the best answer.
A.
IETF
B.
Internet Explorer
C.
Persistent Client State HTTP
D.
RFC-2109
The correct answer is D.
RFC-2109 cookies are different from Netscape cookies and should be used with caution. A is incorrect because it refers to the IEFT, where proposals are submitted for standardization. B refers to a different browser that may not work as expected with Netscape cookies and C refers to the specification, not to the actual cookies.
3.
What special considerations should you remember when setting and receiving cookies?
Please select the best answer.
A.
The cookie shows up before a complete round-trip
B.
The set-cookie header needs to be set after the beginning of the headers
C.
$ENV{COOKIE-HTTP} needs to be checked to see what cookies are coming back
D.
The cookie header must be properly formatted
The correct answer is D.
When you want to set a cookie in the browser, the server must send a Set-cookie: header like this (Set-cookie: UserID=007) so that when the same browser connects back to that same site, it sends this type of cookie:
Cookie: UserID=007.