W
W
wlad19912015-02-24 23:55:11
Google
wlad1991, 2015-02-24 23:55:11

How to write the cookie value to a variable in the background page?

how to write the cookie value to a variable in the background page, went like this:
var ccc=chrome.cookies.get({"url": " vk.com ", "name": "1"}, function(cookies){
callback(cookies .value);
});
alert(ccc);
writes that he does not find

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
SagePtr, 2015-02-25
@SagePtr

The call is asynchronous, because the ccc variable will not have a value (well, or it will obviously not be what you expect). Catch in the callback function and do what you need there.

S
Shaks, 2015-02-25
@shaks

I don’t understand what the background page means, but judging by the presence of vk.com, it probably means cross-domain cookie fencing. If so, then the answer is no.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question