The session module can be used to create or access the browser session present inside each renderer process or the rendered page. The events and methods provided by the session object are very useful: proxy the requests, intercepting the content download and emulating the network usage, and so on. Let's look into the details of the session API.
Session API is a getter property available under web content API. This means that you can access the session of the current page using session property of web content API. We will discuss web content API later in this book. Here is the basic example of getting the current session of a web page inside Electron shell:
const { session, app, BrowserWindow } = require('electron'); let appShell; const appUrl = `file://${__dirname}/index.html`; function createElectronShell() { appShell = new BrowserWindow({ width: 800, height: 600 }); appShell.loadURL(appUrl); // Get default session object const ses = appShell.webContents.session; ...