Separate session for each window
Asked Answered
V

3

30

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?

Volz answered 9/11, 2012 at 4:7 Comment(3)
Hey, your idea sounds cool! Can you let me know if you ever finished it and what it's called?Stitt
The only time when IE excels in something. IE has that.Bi
that would be a legitimate dev-tool. When you need to compare different user types or roles etc.Whirlwind
I
30

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"
Icosahedron answered 16/4, 2015 at 5:18 Comment(3)
We used this approach but it was kind of annoying for the user. With every window opened it asks again about things like "Set as default" or "Translate language" or "Save passwords". To prevent this you can for example copy the contents of another user data directory which has all these question already answered, like the default one.Mezcaline
I tried opening two chromes from the command line, one with --user-data-dir=temp1 and the using temp2, but the two windows were sharing a session.Boabdil
Sad that for every window we open with this method it creates an 80MB profile folder.Hemimorphite
S
1

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%"
Shiite answered 9/10, 2018 at 15:42 Comment(0)
W
0

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".

Wiatt answered 27/3, 2020 at 22:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.