B4J Question [Server] How to enable persistent sessions?

mindful

Active Member
Licensed User
Hi all, I posted a code snippet that allows to enable persistent session on jetty embeded (jServer)

https://www.b4x.com/android/forum/threads/server-persistent-sessions.72825/

But there is a problem after I enable persistent session with the code from above, it saves the sessions correctly and it also loads them as it should if the server is restarted, but after it restores the sessions all session have maxInactiveInterval set to -1393754107, so the sessions will never expire...

Why so ? probably a bug somewhere ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I don't know what is the problem in the code you posted. However i recommend you to use a database instead for data that needs to be persisted.
It will give you more control over the data.

There is no reason to restart the server frequently (it can run for months / years without a restart). Important data should be stored in a database (or MongoDB) and state related data should be stored in the server memory.
 
Upvote 0

mindful

Active Member
Licensed User
ok I will try to setup persistent session with mysql.

I do not need to save them in mysql, because the web app that i'm developing will be installed on site (on the clients "server") so the server can be any pc, i have no control over that so in case of a power failure the server restarts itself and all the sessions and attributes will be gone. This why I wanted to enable persistent sessions on disk.

I don't understand why only the maxInactiveInterval isn't saved or restored correctly ... all other session properties are correct (creation time, last acces, session id). I tried searching on google and the only thing that i can come up is that -1393754107 is a "generic" error value (if an error was encountered when getting the value the value will be set to this).

But since my application uses mysql I will try to get jetty to save session data in db.
 
Upvote 0
Top