Separate session for each window

2020-05-19 05:35发布

问题:

I am trying to create an extension where each window of chrome has its own session. We used incognito earlier, but the problem is that while the main window and the incognito window have separate sessions, the session is shared between the various incognito windows.

Is there any way of configuring chrome to use a separate session every time an incognito window is opened?

回答1:

Your goal will be start a Chrome instance with a new user data directory. The cookies will be isolated in each instance. In the extension to implement a way to reach the same goal as this command on cmd:

chrome.exe --user-data-dir="C:\temp\user1"


回答2:

I had a similar problem where i want to use google chrome for browsing and debugging for work and chrome is pretty original when it comes to sessions. I wrote this small batch script to duplicate the default profile, clear session information and then use the new profile. Old duplicate profiles are also cleared before the new ones are created. The result is a new session with all the old profile stuff.

@echo off

rem folder prefix for the new profile folder
set folderNameStart=profile_

rem generate and format the date creating the new folder name
For /f "tokens=1-6 delims=/ " %%a in ('date /t') do (set mydate=%%c%%b%%a)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
set folderName=%folderNameStart%%mydate%%mytime%%random%

rem set the profile path and the folder destination as well as the directory to 
delete
set profilePath="C:\Documents and 
Settings\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default"
set profileDestination="C:\Documents and 
Settings\%USERNAME%\AppData\Local\Google\Chrome\User Data\"%folderName%
set profileLocation="C:\Documents and 
Settings\%USERNAME%\AppData\Local\Google\Chrome\User Data\"

rem iterate through directory and delete all the existing profile folders
CD %profileLocation%
echo %profileLocation%
for /D /r %%G in ("%folderNameStart%*") do rmdir /q /s "%%G"

rem this will copy the old profile directory 
echo D | xcopy %profilePath% %profileDestination%

rem delete the session storage and its contents if its exist
rmdir /q /s "C:\Documents and Settings\%USERNAME%\AppData\Local\Google\Chrome\User 
Data\%folderName%\Session Storage"


rem start google chrome with the new profile folder
start "Chrome" "C:\Program Files\Google\Chrome\Application\chrome.exe" --profile-directory="%folderName%"


回答3:

To make it work need to know difference between open "new window" in chrome, if there no difference then no way to do it in that case. Another way if know what difference when use incognito mode and use it to add in chrome "Open tab in new window pofile 1".