Fork me on GitHub
#ring
<
2019-12-02
>
Pavel Klavík14:12:17

Hi, what is the common approach to deal with session timeouts? For instance when a user wake up laptop after a while. How should I detect on the client that session timeouted?

weavejester23:12:32

You can store a timestamp when the session is created, and delete the session if it exceeds the timestamp.

Pavel Klavík05:12:40

@U0BKWMG5B But that is on the server, isn't it? Should I set a timeout on the client as well? How to deal with the situation when session is extended after a user action?

weavejester11:12:07

You can also set a timeout on the client. Some sites do, some sites don’t. If you want to, you’d take the timestamp from the session and generate some javascript to trigger a function after a timeout. To extend the timeout, you can just update the session value on user action.

Pavel Klavík23:12:05

How do I get a timestamp from the session? How is it stored on the client?

Pavel Klavík23:12:05

@U0BKWMG5B Our application is something close to Google Docs, so it is a tool which users should use over long periods of time. Ideally, after waking up laptop, it should get refreshed automatically and be ready to work.

weavejester01:12:51

You just generate the current date or timestamp and add it to the session. Are you asking how to generate a time in Clojure, or how to store things in the session?

Pavel Klavík10:12:43

So I store the time in the session on the server. How do I access it on the client?

weavejester17:12:59

You can generate a <script> tag in order to pass additional information to your client scripts. Or have the client make an Ajax call.

Pavel Klavík02:12:37

Ok, makes sense, I will try to build some prototype and will see how it works. Thanks.