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?
@weavejester 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?
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.
How do I get a timestamp from the session? How is it stored on the client?
@weavejester 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.
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?
So I store the time in the session on the server. How do I access it on the client?
You can generate a <script>
tag in order to pass additional information to your client scripts. Or have the client make an Ajax call.
Ok, makes sense, I will try to build some prototype and will see how it works. Thanks.
You can store a timestamp when the session is created, and delete the session if it exceeds the timestamp.