Hi

I want the session to be expired if the it is idle for 5 minutes.

I have the following client code after a successful login:

String sessionID = /* (Get sessionID from server's response to login
request.) */ ;
long DURATION = 1000 * 60 * 5;
Date expires = new Date(System.currentTimeMillis() + DURATION);
// the sid cookie will be expired after 5 min
Cookies.setCookie("sid", sessionID, expires, null, "/", false);


The problem with the above code is that the session cookie will be expired 5
minutes from the time the session is created and not from the time the last
request to the server.
For example, if a session is created at 00:00, followed by a request at
00:04, the cookie will still expire at 00:05 instead of 00:09.

To do this, I have to reset the expiry time of the cookie in every RPC call
like the following:

public void onFailure(Throwable caught) {
    ...
    // re-calculate the expiry time
    Date expires = new Date(System.currentTimeMillis() + DURATION)
    Cookies.setCookie("sid", sessionID, expires, null, "/", false);
}

public void onSuccess(...) {
    ...
    // re-calculate the expiry time
    Date expires = new Date(System.currentTimeMillis() + DURATION)
    Cookies.setCookie("sid", sessionID, expires, null, "/", false);
}


May I know if there a more elegant way of doing this?


-- 

Hez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to