Hello!
I hava JDBCRealm auth, and want to store user's last_accessed time. i
thought cookies would be good for that. my code is as follows:
Locale l = new Locale("pl","PL","UNIX");
String user = request.getRemoteUser();
String data="";
boolean found = false;
Cookie[] cookies = request.getCookies();
for (int i = 0; i cookies.length; i++) {
Cookie c = cookies[i];
if (c.getName().equals(user)) {
found=true;
data = c.getValue();
c.setValue(DateFormat.getDateTimeInstanceDateFormat.LONG,DateFormat.LONG,l).
format(new Date()));
}
}
if (!found) {
String bla =
DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG,l).format(new
Date());
Cookie newC = new Cookie(request.getRemoteUser(),bla);
newC.setMaxAge(10);
response.addCookie(newC);
}
then variable data would return last_accessed time. but it doesnt! that is a
call to setValue(DateFormat...) is not stored in a cookie for good, only
temporary. only for the new user a new cookie with a proper access time is
stored.
anybody?
thanks.
vVolf
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]