I've just built my first Chrome app (https://chrome.google.com/webstore/detail/gitter/ldhcdmnhbafhckhidlhdbeekpifobpdc) and am experiencing a problem with cookies.

The app effectively boots an index.html page in a window, which has a webview pointing at our regular web application.

If I Quit Chrome on my Mac, every time I launch the Gitter Chrome App, any cookies seem to have been wiped out and so I have to login again (and also login to GitHub again).

I can't quite exactly figure out where to start looking, if anyone has any pointers, I would much appreciate it.

PS. I've checked this question & answer out (chrome Extension : Set persistent cookie in chrome extension?) and as far as I can tell my problem isn't related to non-expiring cookies as we do set expiration on the cookies.

My manifest looks like this:

{
   "app": {
      "background": {
         "scripts": [ "launch.js" ]
      }
   },
   "description": "Chat for GitHub.",
   "icons": {
      "128": "icon-128.png",
      "16": "icon-16.png"
   },
   "manifest_version": 2,
   "name": "Gitter",
   "short_name": "Gitter",
   "offline_enabled": true,
   "permissions": [
    "unlimitedStorage",
    "notifications",
    "webview",
    "http://*/*"
  ],
   "version": "1.0.0.3"
}

and the page it boots into a window basically does this:

<webview id="wv1" style="width:100%; height:100%;"
  src="https://gitter.im/">
</webview>
有帮助吗?

解决方案

I think you need to add a partition attribute to your webview tag with a value starting with persist:

partition

Storage partition ID used by the webview tag. If the storage partition ID starts with persist: (partition="persist:googlepluswidgets"), the webview will use a persistent storage partition available to all guests in the app with the same storage partition ID. If the ID is unset or if there is no persist: prefix, the webview will use an in-memory storage partition.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top