Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Extension in incognito mode

I have an extension for Chrome that makes ajax request to my site. The site uses sessions. So, in response of the ajax request to the site, the Set-Cookie header is returned with some session identifier and a this entry appears in the cookie section of the extension DevPanel (of the backgroud page). But, session id in the DevPanel browser for the site is a completely different. Extension is allowed for incognito mode.

In normal mode, the cookies are identical in the DevPanels of the extension and the browser. I understand that cookies for normal and incognito modes should be different, but why are these values ​​different for the extension allowed for incognito mode?

Am I right and extensions allowed for incognito mode, work in normal mode?

like image 347
Vitaly Avatar asked Dec 19 '22 07:12

Vitaly


1 Answers

The solution was suggested to me in the chrome discussion group.

There is a key "incognito" in extension manifest with three values: "spanning" (default), "split" and "not_allowed".

More about this key you can read here: https://developer.chrome.com/extensions/manifest/incognito.

To solve my problem it was enough to set value "split" for this key. In this case are opened two separate processes for extension - for normal and for incognito modes. If browser is opened in incognito mode, then the "incognito" extension process will be used.

And now, ajax requests in incognito mode get right session cookie.

P.S. If you're developing crossbrowser extension, note, that Firefox still (today: 2017-12-11) supports only "spanning" value for "incognito" key.

like image 172
Vitaly Avatar answered Jan 21 '23 18:01

Vitaly