session.defaultSession static property
The session.defaultSession property is the Session of the default partition. All web pages created without partition share this partition.
Value
A Session.
- Read-only. The
sessionobject is frozen, so assigning to it has no effect: in strict mode it throwsTypeError. - Every read returns the same object;
session.defaultSession === session.defaultSessionholds. - It is the same object as
session.fromPartition('')andsession.fromPartition('persist:'). - The default partition's data survives an app restart;
isPersistent()returnstrue.
It works without creating a web page first.
Examples
js
const ses = session.defaultSession;
console.log(ses === session.fromPartition(''));
console.log(ses.isPersistent());Result: It prints true, then true.
Differences from Electron
session is a global object; no require('electron') is needed. Everything else is the same.
The corresponding iOS API is WKWebsiteDataStore.defaultDataStore.
See also
session.fromPartition(): other partitions- Partitions: how the kinds of partitions differ