Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
How to create a persistent on-disk session in ElectronJS?

How do I create a session which is persistent with on-disk storage so that I can load it even after the app quits? The Session class has a storagePath property which returns an absolute file system path for the session if it persists on disk, but this property is read-only.

I can't seem to find a way to set this path, the API reference doesn't contain any helpful methods.

So how do I make my session persist on disk?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The Session class has a storagePath property which returns an absolute file system path for the session if it persists on disk, but this property is read-only.

I can't seem to find a way to set this path, the API reference doesn't contain any helpful methods.

So how do I make my session persist on disk?

It's not very intuitive, but the ses.fromPartition API docs state:

If partition starts with persist:, the page will use a persistent session available to all pages in the app with the same partition. if there is no persist: prefix, the page will use an in-memory session. If the partition is empty then default session of the app will be returned.

For example:

const { session } = require('electron');

const ses = session.fromPartition('persist:my-partition');
console.log(ses.isPersistent()) // true 
console.log(ses.getStoragePath()) // /Users/user/Library/Application Support/app/Partitions/my-partition (on macOS)

Then the session partition path should be /USERDATA/Partitions/my-partition, where USERDATA is the value of app.getPath('userData').

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!