nerdexam
GIAC

GPEN · Question #401

Which of the following is the JavaScript variable used to store a cookie?

The correct answer is C. Document cookie. JavaScript accesses and manipulates browser cookies through the document.cookie property exposed by the Document Object Model.

Web Application Penetration Testing

Question

Which of the following is the JavaScript variable used to store a cookie?

Options

  • ABrowsercookie
  • BWindowcookie
  • CDocument cookie
  • DSession cookie

How the community answered

(62 responses)
  • A
    3% (2)
  • B
    10% (6)
  • C
    81% (50)
  • D
    6% (4)

Why each option

JavaScript accesses and manipulates browser cookies through the document.cookie property exposed by the Document Object Model.

ABrowsercookie

Browsercookie is not a valid property, object, or interface in any JavaScript specification or browser Web API.

BWindowcookie

Windowcookie is not a property of the window object or any other JavaScript built-in - it does not exist in the Web API.

CDocument cookieCorrect

In the browser's Document Object Model, document.cookie is the standard and only native JavaScript property used to read, create, update, and delete cookies for the current document. Reading document.cookie returns a semicolon-delimited string of all name-value cookie pairs in scope, and assigning a new string to it sets or updates an individual cookie, making it the correct JavaScript interface for all cookie operations.

DSession cookie

Session cookie describes a category of cookie (one with no expiry date, deleted when the browser session ends), not a JavaScript variable or property used to access or store cookies.

Concept tested: JavaScript document.cookie DOM property for cookies

Source: https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie

Topics

#JavaScript#document.cookie#cookie access#web storage

Community Discussion

No community discussion yet for this question.

Full GPEN Practice