public Long getCurrentUserId() { try { String str = cookie.readCookieValue("careerbus:uid"); return Long.parseLong(str); } catch (NumberFormatException e) { } return null; }
public void setClientTimeZone(TimeZone timeZone) { assert timeZone != null; identified = true; if (timeZone == this.timeZone) return; this.timeZone = timeZone; cookies.writeCookieValue(COOKIE_NAME, timeZone.getID()); // Write to the Session, if it exists, in case the client doesn't support cookies. Session session = request.getSession(false); if (session != null) session.setAttribute(ATTRIBUTE_NAME, timeZone.getID()); // Worst case: no session yet AND client doesn't support cookies. That means we'll likely // keep tracking the time zone (on the client) and updating (here on the server) until // a session gets created. }
private TimeZone readTimeZoneFromCookie() { String id = cookies.readCookieValue(COOKIE_NAME); return id == null ? null : TimeZone.getTimeZone(id); }
public void setCurrentUserId(Long userId) { cookie.writeCookieValue("careerbus:uid", userId + ""); }