Why is chrome.cookies undefined in a content script?
Quoting the docs about content scripts:
[Content scripts cannot] Use chrome.* APIs (except for parts of chrome.extension)
So, to use chrome.cookies
API, you need to do so from a background page, communicating with the content script if needed.
In case someone skipped this, be sure to add "cookies" to permissions.