Docs

Session (window.Electron.session)

Cache, storage, proxy, user-agent, and cookie control for the calling window's Electron Session. Source: src/main/session.ts, channel prefix session:*. Always on, no config needed.

Every call is scoped to the Session of the webContents that sent it (falling back to session.defaultSession if that can't be resolved) — there's no way to reach into a different window's session from this module.

Methods

Method Returns Notes
clearCache() Promise<void>
clearStorageData(options?: Electron.ClearStorageDataOptions) Promise<void> Pass-through to Electron's session.clearStorageData().
getUserAgent() Promise<string>
setUserAgent(userAgent: string) Promise<void>
resolveProxy(url: string) Promise<string>
setProxy(config?: Electron.ProxyConfig) Promise<void> Pass-through to session.setProxy().
closeAllConnections() Promise<void>
getCookies(filter?: Electron.CookiesGetFilter) Promise<Electron.Cookie[]> Pass-through to session.cookies.get().
setCookie(cookie: Electron.CookiesSetDetails) Promise<void> Pass-through to session.cookies.set().
removeCookie(options: { url: string; name: string }) Promise<void> Pass-through to session.cookies.remove(url, name).

Example

await window.Electron.session.setUserAgent('MyApp/1.0');
const cookies = await window.Electron.session.getCookies({ domain: 'example.com' });
await window.Electron.session.clearStorageData({ storages: ['cookies', 'localstorage'] });

.safe

Fully mirrored — window.Electron.safe.session.* resolves { ok: true, data } / { ok: false, error } instead of throwing.

Last updated on July 18, 2026