How to read cookies with localhost?

I am trying to develop a Chrome extension, and the first step is to determine if the user is registered on my website. I'm testing for development localhost, so how can I read cookies for writing?

Here is what is in my manifest:

"permissions": [
    "cookies", "tabs", "http://*/*", "https://*/*"
],

And JavaScript:

chrome.cookies.get({"url": 'localhost', "name": '_ga'}, function(cookie) {
    console.log('cookie:');
    console.log(cookie);
}); 

But I get this error:

Unchecked runtime.lastError while running cookies.get: Invalid url: "localhost".

Can someone point me in the right direction?

+4
source share
1 answer

localhostis not a valid URL; it is simply the name of the [perceived] host.

Use http://localhostwith enabled protocol for URL.

+2
source

All Articles