Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Update browser_use/browser/session.py

Nick Sweeting6d8ce0bafdc4
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index edbd488ca..7270e04ae 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -1258,7 +1258,7 @@ class BrowserSession(BaseModel):
# assume they're using the old API when path meant a cookies_file path,
# also save new format next to it for convenience to help them migrate
await self._save_cookies_to_file(cookies, path)
- await self._save_storage_state_to_file(storage_state, path.parent / 'storage_state.json')
+ await self._save_storage_state_to_file(storage_state, (Path(path or self.browser_profile.cookies_file).parent) / 'storage_state.json')
logger.warning(
'⚠️ cookies_file is deprecated and will be removed in a future version. '
'Please use storage_state="path/to/storage_state.json" instead for persisting cookies and other browser state. '