Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

raven89's avatar

Not able to set Chrome local storage in extension (undefined)

I have a Chrome extension I'm trying to read and write to local storage with like this:

chrome.storage.local.set({lty_username: username}, function(){ if (chrome.runtime.lastError) { console.error(chrome.runtime.lastError); } else { console.log("Username saved: " + username); } });

chrome.storage.local.get(["lty_username"]).then((result) => { alert("Value currently is " + result.key); });

But when I read the same key/value set to local storage, it is always undefined. There are no errors in the console https://100001.onl/ .

Here's is my manifest.json file:

{ "name": "name", "version": "1.0.0", "description": "description", "manifest_version": 3, "author": "author", "action":{ "default_popup": "index.html", "default_title": "title" }, "host_permissions": [ "://.facebook.com/", "://.twitter.com/", "://.linkedin.com/", "://.nextdoor.com/", "://.instagram.com/", "://.reddit.com/", "://.quora.com/" ], "permissions": [ "cookies", "storage" ] }

I can't figure out why values are not being set in local storage. Anyone know why?

0 likes
0 replies

Please or to participate in this conversation.