Document Object Model And Event Handling - Study Mode
[#106] The Cookie manipulation is done using which property?
Correct Answer
(A) cookie
Explanation
Solution: 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.
[#107] Which attribute is used to extend the lifetime of a cookie?
Correct Answer
(C) max-age
Explanation
Solution: 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. If you specify a lifetime, the browser will store cookies in a file and delete them only once they expire.
[#108] Which of the following defines the Cookie visibility?
Correct Answer
(D) all of the mentioned
Explanation
Solution: Cookie visibility is scoped by document origin as localStorage and sessionStorage are, and also by document path.
[#109] Which of the following can be used to configure the scope of the Cookie visibility?
Correct Answer
(D) none of the mentioned
Explanation
Solution: The Cookie visibility scope is configurable through cookie attributes path and domain.
[#110] How can you set a Cookie visibility scope to localStorage?
Correct Answer
(A) /
Explanation
Solution: 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.