Persistent backend variables?

I’m want to create a unique ID string on the backend that gets compared to a string sent from the frontend. It needs to be persistent across all the backend scripts and only accessible from server side scripts.

I don’t see a backend equivalent to wix-storage for persistent variables. Searching the forums hasn’t given me what I need.

In PHP I usually do this using the $_SESSION object which is only accessible from the server side.

Is there anything like that in Wix code?

Any updates?

Try using npm Global module on backend .jws

Can you elaborate? Code example would be awesome. Need to have a available to the backend only, persisting between function calls.

Y can use this or global. ‘this’ is an instance of global on node session.

set.jws
var global = require (“global”)
var document = require( “global/document” )
var window = require( “global/window” )

export function set() {
this.myVar = {obj: ‘json’}
global[‘var’] = ‘using global npm’
console.log(‘Set this’, this, this.myVar)
console.log(‘Set global’, global, global.var)
}

get.jws (another file)
export function get() {
console.log(‘Get this’, this, this.myVar)
console.log(‘Get global’, global, global.var)
}

Wix page1 code
import {set} from ‘backend/set’;

Wix page2 code
import {get} from ‘backend/get’;

You don’t need to import the npm module twice. You just need to import on first jsw file called.