2

I'm trying to use the google chrome cookies extension when developing a chrome extension app. I've followed the instructions found here: http://code.google.com/chrome/extensions/cookies.html

My manifest file already has the permissions and cookies.

The problem is now I can't seem to call any of the methods in the cookies extension

var newCookie = {'url:': 'http://*/*', 'name': 'routeCookie', 'value': route.tag[document.boxForm.routeBox.options.selectedIndex]};
chrome.cookies.set(newCookie);

Error: UnCaught TypeError: Cannot call method 'set' of undefined

infinityLoop
  • 366
  • 4
  • 20

1 Answers1

8

I bet you are trying to run it from a content script. Most API methods are available only in background pages.

serg
  • 109,619
  • 77
  • 317
  • 330
  • I'm guessing the same, and if that is the case you will need to [pass a message](http://code.google.com/chrome/extensions/messaging.html) to the background page. For more information on content scripts [read the documentation](http://code.google.com/chrome/extensions/content_scripts.html). – neocotic Jul 28 '11 at 12:27
  • I think that is the case. I will read up on the content script and message passing and get back to you guys. Thanks! – infinityLoop Jul 28 '11 at 12:33
  • Here is some more additional information for future reference: http://stackoverflow.com/questions/6232443/obtain-cookies-of-the-page-being-visited – infinityLoop Jul 28 '11 at 13:58