Important note: Chrome is designed to have one session per profile. Opening multiple independent sessions with the same profile simultaneously can cause:
Sync conflicts
Cookie/session corruption
Unexpected behavior
If you're trying to test something or need multiple sessions, it's usually better to use different profiles or incognito windows. What specific use case are you trying to achieve? There might be a better approach.
User
I need like 30 chromes with same cookies with different debugger addresses
Assistant
For running 30 Chrome instances with the same cookies and different debugger addresses, you'll need to:
Method 1: Copy profile and launch with unique ports
First, close all Chrome instances
Copy your Chrome profile folder 30 times:
bash
# Windows example
for /l %i in (1,1,30) do xcopy "%LOCALAPPDATA%\Google\Chrome\User Data" "C:\ChromeProfiles\Profile%i\" /E /I /Y
# Linux/Mac example
for i in {1..30}; do cp -r ~/.config/google-chrome ~/ChromeProfiles/Profile$i; done
Launch each instance with a unique debugging port:
bash
# Windows
start chrome.exe --user-data-dir="C:\ChromeProfiles\Profile1" --remote-debugging-port=9222
start chrome.exe --user-data-dir="C:\ChromeProfiles\Profile2" --remote-debugging-port=9223
# ... and so on
# Linux/Mac
google-chrome --user-data-dir="~/ChromeProfiles/Profile1" --remote-debugging-port=9222 &
google-chrome --user-data-dir="~/ChromeProfiles/Profile2" --remote-debugging-port=9223 &
Method 2: Automated script approach
Create a batch/shell script:
bash
# Windows batch script
@echo off
for /l %%i in (1,1,30) do (
start chrome.exe --user-data-dir="C:\ChromeProfiles\Profile%%i" --remote-debugging-port=92%%i
timeout /t 2
)
# Bash script
#!/bin/bash
for i in {1..30}; do
google-chrome --user-data-dir="~/ChromeProfiles/Profile$i" --remote-debugging-port=$((9222+$i)) &
sleep 2
done
Additional useful flags:
--disable-gpu - Reduces resource usage
--no-sandbox - May help with multiple instances
--disable-dev-shm-usage - Helps with memory issues
--headless - If you don't need UI
Important considerations:
This will use significant system resources (RAM/CPU)
Cookie changes won't sync between instances
Some sites may detect and block multiple sessions
Consider using a tool like Puppeteer or Selenium for better control
What's your use case? There might be more efficient approaches using automation frameworks.
User
Can I just load cookies / store profile in memory?
Assistant
Yes, you can run Chrome with profile data in memory and programmatically load cookies. Here are the most efficient approaches:
Method 1: In-memory profile with tmpfs (Linux/Mac)
Method 2: Minimal profile + inject cookies programmatically
python
# Using Selenium/ChromeDriver
from selenium import webdriver
import pickle
# Start with minimal profile
options = webdriver.ChromeOptions()
options.add_argument('--user-data-dir=/tmp/minimal-profile')
options.add_argument('--remote-debugging-port=9222')
driver = webdriver.Chrome(options=options)
# Load cookies from file
with open('cookies.pkl', 'rb') as f:
cookies = pickle.load(f)
for cookie in cookies:
driver.add_cookie(cookie)
Method 3: Puppeteer with cookie injection
javascript
const puppeteer = require('puppeteer');
// Launch browsers with minimal profiles
for (let i = 0; i < 30; i++) {
const browser = await puppeteer.launch({
headless: false,
args: [
`--remote-debugging-port=${9222 + i}`,
'--disable-dev-shm-usage',
'--no-sandbox'
]
});
const page = await browser.newPage();
// Load cookies
await page.setCookie(...cookiesArray);
}
Method 4: Chrome DevTools Protocol directly
python
import requests
import json
# Connect to Chrome debugging port
def set_cookies(port, cookies):
url = f"http://localhost:{port}/json"
tabs = requests.get(url).json()
ws_url = tabs[0]['webSocketDebuggerUrl']
# Use CDP to set cookies
# (requires websocket connection)
Most efficient approach:
Start Chrome with --user-data-dir=/dev/shm/chrome-X (Linux shared memory)
Use only essential profile files (just Cookies, Local Storage)
Inject additional data via CDP or automation framework
This way you avoid copying full profiles and use minimal disk I/O. Would you like a complete script for any of these approaches?