This set of Computer Networks Multiple Choice Questions & Answers (MCQs) focuses on “Cookies”.
1. Cookies were originally designed for ____________
a) Client side programming
b) Server side programming
c) Both Client side programming and Server side programming
d) Socket programming
Explanation: Cookies were originally designed for server side programming, and at the lowest level, they are implemented as an extension to the HTTP protocol. They were introduced with the intention of providing a better user experience for the websites.
2. The Cookie manipulation is done using which property?
d) manipulate cookie
Explanation: The cookie property sets or returns all name/value pairs of cookies in the current document. There are no methods involved: cookies are queried, set, and deleted by reading and writing the cookie property of the Document object using specially formatted strings.
3. Which of the following explains Cookies nature?
a) Non Volatile
Explanation: Cookies are transient by default; the values they store last for the duration of the web browser session but are lost when the user exits the browser. While the browsing session is active the cookie stores the user values in the user’s storage itself and accesses them.
4. Which attribute is used to extend the lifetime of a cookie?
Explanation: If you want a cookie to last beyond a single browsing session, you must tell the browser how long (in seconds) you would like it to retain the cookie by specifying a max-age attribute. A number of seconds until the cookie expires. A zero or negative number will kill the cookie immediately.
5. Which of the following defines the Cookie visibility?
a) Document Path
d) All of the mentioned
Explanation: sessionStorage, localStorage and Document path all are used to store data on the client-side. Each one has its own storage and expiration limit. Cookie visibility is scoped by the document origin as Local Storage and Session Storage are, and also by document path.
6. Which of the following can be used to configure the scope of the Cookie visibility?
c) Both Path and Domain
Explanation: The Cookie visibility scope is configurable through cookie attributes path and domain. Domain attribute in the cookie is used to specify the domain for which the cookie is sent. Path includes the Path attribute in the cookie to specify the path for which this cookie is sent.
7. How can you set a Cookie visibility scope to local Storage?
Explanation: Setting the path of a cookie to “/” gives scoping like that of localStorage and also specifies that the browser must transmit the cookie name and value to the server whenever it requests any web page on the site.
8. Which of the following is a Boolean cookie attribute?
Explanation: The final cookie attribute is a boolean attribute named secure that specifies how cookie values are transmitted over the network. By default, cookies are insecure, which means that they are transmitted over a normal, insecure HTTP connection. If a cookie is marked secure, however, it is transmitted only when the browser and server are connected via HTTPS or another secure protocol.
9. Which of the following function is used as a consequence of not including semicolons, Commas or whitespace in the Cookie value?
10. What is the constraint on the data per cookie?
a) 2 KB
b) 1 KB
c) 4 KB
d) 3 KB
Explanation: Each cookie can hold up to only 4 KB. In practice, browsers allow many more than 300 cookies total, but the 4 KB size limit may still be enforced by some. Storage of a session has to be a minimum of 5MB.
Sanfoundry Global Education & Learning Series – Computer Networks.
To practice all areas of Computer Networks, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Get Free Certificate of Merit in Computer Networks
- Participate in Computer Networks Certification Contest
- Become a Top Ranker in Computer Networks
- Take Computer Networks Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Apply for Computer Network Internship
- Buy Computer Science Books
- Practice Computer Science MCQs
- Apply for Computer Science Internship
- Buy Computer Network Books