Is there a way for me to set a chrome cookie everytime it is changed? I’ve tried
<select id="routeBox" name="routeBox"
onchange="getRoute(route, routeBox.selectedIndex);
chrome.cookies.set({'url':'http://127.0.0.1/', 'name':'routeCookie', 'value': this.options.selectedIndex});">
</select>
Ignore getRoute, it just calls an xml parser again to re-populate the selectBox.
The cookie part doesn’t seem to work. I’ve also tried creating a function that is called onchange but it doesn’t work either.
<select id="routeBox" name="routeBox"
onchange="getRoute(route, routeBox.selectedIndex);
setCookies('http://127.0.0.1/','routeCookie', this.options.selectedIndex);">
</select>
function setCookies(domain, name, value) {
chrome.cookies.set({'url': domain, 'name': name, 'value': value});
alert("cookie set");
}
Also: Here is a snippet of my manifest file
"permissions": [
"cookies", "tabs",
"*://*/*"
],
"content_scripts": [
{
"matches": ["http://127.0.0.1/*", "*://*/*"],
"js": ["functions.js"]
}
As always any help or comments would be great!
Amaan Cheval has provided me with this solution:
Use HTML 5 LocalStorage!
This was a simple workaround that while may not be backwards compatible friendly, seems to be able to replace cookies quite effectively.