-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Electron: Session
Used to manage browser sessions, cookies, cache, proxy settings, etc.
-
Access the
session
of existing pages by using thesession
property ofWebContents
.const { BrowserWindow } = require('electron') const win = new BrowserWindow({ width: 800, height: 600 }) win.loadURL('http://github.com') const ses = win.webContents.session console.log(ses.getUserAgent())
-
Access the default session object of the app by using the
defaultSession
property ofsession
module.const { session } = require('electron') console.log(ses.defaultSession)
-
session.fromPartition(partition[, options])
-
Code illustrator
const { session } = require('electron') const ses = session.fromPartition('persist:name') console.log(ses.getUserAgent())
-
Return a session instance from
partition
string. If there is an existingSession
with the samepartition
, it will be returned, otherwise a newSession
instance will be created. -
If
partition
starts withpersist:
, the page will use a persistent session available to all pages in the app with the samepartition
. -
If there is no
persist:
prefix, the page will use an in-memory session. -
If the
partition
is empty, the default session of the app will be returned.
-