# Cookies

Examples of managing cookies in Cypress, for a full reference of commands, go to docs.cypress.io

#### Cypress.Cookies.debug()

To enable or disable cookie debugging, use `Cypress.Cookies.debug()`.

    // Cypress will now log in the console when
    // cookies are set or removed
    Cypress.Cookies.debug(true)

    Cypress.Cookies.set('fakeCookie', '123ABC')
    Cypress.Cookies.remove('fakeCookie')
    Cypress.Cookies.set('fakeCookie', '123ABC')
    Cypress.Cookies.remove('fakeCookie')
    Cypress.Cookies.set('fakeCookie', '123ABC')

#### Cypress.Cookies.preserveOnce()

To preserve cookies by its key, use `Cypress.Cookies.preserveOnce()`.

    expect(Cypress.Cookies.get('fakeCookie')).to.not.be.ok

    Cypress.Cookies.set('lastCookie', '789XYZ')
    Cypress.Cookies.preserveOnce('lastCookie')

#### Cypress.Cookies.default()

To set defaults for all cookies, use `Cypress.Cookies.default()`.

    Cypress.Cookies.defaults({
      whitelist: "session_id"
    })