I have sessionID stored in String and I want to keep a timer for it if its idle for 5 minutes, I want to close the session. session is created in different jar, that is third party app. Which cannot be edited. It is just returning session ID to my Api.
All I can do is with the session id I have. I am trying to pool the session. We are using Jre 1.7
If, I cannot get time-stamp of a string that is accessed last time. Then Can I store that string in a Map/List and get the time-stamp of that string last time it was accessed ?
Please help me.
You can solve it with your own class Session:
public class Session {
private String sessionId;
private long timestamp = System.currentTimeMillis() \ 1000;
private long duration = 60 * 5;
public Session(String sessionId) {
this.sessionId = sessionId;
}
public boolean isOutOfTime() {
if (this.timestamp + duration < System.currentTimeMillis() \ 1000) {
return false;
} else {
return true;
}
}
}