Computer Networks Questions & Answers – 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) None of the mentioned
a) Client side programming
b) Server side programming
c) Both Client side programming and Server side programming
d) None of the mentioned
Answer: b
Explanation: Cookies were originally designed for server side programming, and at the lowest level, they are implemented as an extension to the HTTP protocol.
Explanation: Cookies were originally designed for server side programming, and at the lowest level, they are implemented as an extension to the HTTP protocol.
2. The Cookie manipulation is done
using which property?
a) cookie
b) cookies
c) manipulate
d) none of the mentioned
a) cookie
b) cookies
c) manipulate
d) none of the mentioned
Answer: a
Explanation: 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.
Explanation: 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
b) Volatile
c) Intransient
d) Transient
a) Non Volatile
b) Volatile
c) Intransient
d) Transient
Answer: d
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.
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.
4. Which attribute is used to extend
the lifetime of a cookie?
a) Higherage
b) Increaseage
c) Maxage
d) Lifetime
a) Higherage
b) Increaseage
c) Maxage
d) Lifetime
Answer: c
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 manage
attribute. If you specify a lifetime, the browser will store cookies in a file and delete them only once they expire.
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 manage
attribute. If you specify a lifetime, the browser will store cookies in a file and delete them only once they expire.
5. Which of the following defines
the Cookie visibility?
a) Document Path
b) LocalStorage
c) SessionStorage
d) All of the mentioned
a) Document Path
b) LocalStorage
c) SessionStorage
d) All of the mentioned
Answer: d
Explanation: Cookie visibility is scoped by document origin as local Storage and session Storage are, and also by document path.
Explanation: Cookie visibility is scoped by 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?
a) Path
b) Domain
c) Both Path and Domain
d) None of the mentioned
a) Path
b) Domain
c) Both Path and Domain
d) None of the mentioned
Answer: d
Explanation: The Cookie visibility scope is configurable through cookie attributes path and domain.
Explanation: The Cookie visibility scope is configurable through cookie attributes path and domain.
7. How can you set a Cookie
visibility scope to local Storage?
a) /
b) %
c) *
d) All of the mentioned
a) /
b) %
c) *
d) All of the mentioned
Answer: a
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.
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?
a) Bool
b) Secure
c) Lookup
d) Domain
a) Bool
b) Secure
c) Lookup
d) Domain
Answer: b
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.
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?
a) EncodeURIComponent()
b) EncodeURI()
c) EncodeComponent()
d) None of the mentioned
Commas or whitespace in the Cookie value?
a) EncodeURIComponent()
b) EncodeURI()
c) EncodeComponent()
d) None of the mentioned
Answer: a
Explanation: Cookie values cannot include semicolons, commas, or whitespace. For this reason, you may want to use the core JavaScript global function encodeURIComponent() to encode the value before storing it in the cookie.
Explanation: Cookie values cannot include semicolons, commas, or whitespace. For this reason, you may want to use the core JavaScript global function encodeURIComponent() to encode the value before storing it in the cookie.
10. What is the constraint on the
data per cookie?
a) 2 KB
b) 1 KB
c) 4 KB
d) 3 KB
a) 2 KB
b) 1 KB
c) 4 KB
d) 3 KB
Answer: c
Explanation: Each cookie can hold upto 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.
Explanation: Each cookie can hold upto 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.
ليست هناك تعليقات:
إرسال تعليق