Plans for Express sessions store

Hi team,

Have you already planned adding a session store for express?

I don’t know if anybody has gone already live with a nodejs project but this is going to be needed if people don’t want to logout all their users every time they upload a change to the server.

3 Likes

Thanks for raising this JonL. Going live in phases with our NodeJs starting tomorrow, so this is timely.

2 Likes

Yup experiencing this for mobile project where we need to deploy live for testing

2 Likes

Knex DB store and filesystem store seem to be two good options for what Wappler has and does.

More powerful features for the future could be redis or memcached.

2 Likes

I made some quick tests for filesystem store and it works a charm. Sessions are persistent after a server restart.

On the default config the fs store will store in /sessions the session files.

image

There are some changes needed to some core files(that could be rewritten in the future) so I am hoping they can add it soon to the core. (@george)

Additionally, as FS store won’t work on hosting providers with non-persistant storage(like Heroku) it is important also to offer an alternative. I will probably conduct some testing later on for the knex db driven session store. Both options seem to be quite straightforward.

2 Likes

Passport would also have session capabilities, correct or would it also need a session store?

This is indeed something that would be needed, but I’m not sure on how we would implement this within Wappler. I don’t want to include all possible stores directly, they should be optional and that is currently not possible. Also each store needs different code, we need to somehow make this dynamic, so that you can easily set it with some config options and do not need to code it yourself.

It is already possible to change the config for the sessions using the config.json, but the store needs an instance as value and this can not be set using json.

1 Like

I believe you still need a persistent store(if you need persistence).
If not provided it defaults to memory store.

Yep, it’s actually a big deal for user experience.

I was just asking if it was a normal behavior to be logged out after a push.

2 Likes

+1 For a way to set this up or at least a guide (@JonL that test you’ve done for filesystem store, is that something that can be used with a DigitalOcean droplet?)

Btw to just handle the being logged out issue, just use a remember me options with the login so a cookie is used and next time the user is auto logged in.

Yes as DO has persistent storage.

As I normally use providers without persistent storage I had to go with a Postgres based session store.

@George When I set the ‘remember me’ with the login it indeed makes the cookie BUT when I deploy again it still forces me to log in again.

See video:

Am I understanding you wrong George, or is it a bug?

1 Like

Hello @JonL, making sessions persistent after a server restart sounds great!. Could you share a bit more on how you accomplished this to give it a try?

Thank you!

We already have the possibilities for using Redis as session store.

When you enable Redis - just as for caching, it will be used for session store as well:

Hello George, thank you for the response and the link.

I didn’t realize Redis Caching could help with session store as well.

Just to clarify, by

just as for caching, it will be used for session store as well

Are you referring to the action of -querying the db for a user’s data based on the SecurityProvider identity- being cached by Redis?

Or does “Using Redis as a session store” mean something different.

Best regards.

Hi George, pls correct me if im wrong, but I read that Redis can only be used with Docker, unfortunately I do not use docker in production since my hosting gives me Cpanel with the Nodejs implementation. I hope you can integrate it for those of us who work without docker.

2 Likes

What kind of session store would you prefer, what is possible with your host? Options could be using the file system or an existing database. We could perhaps also support an external redis server.

I saw you have already a half-baked knex and file store.

For now and for future I would always try to make any integration compatible with docker and externally if possible.

I am using a knex based store and I use an external database. Once redis is available externally I will swap from knex to redis. Also for the cache.