Class SessionUtil
java.lang.Object
fc.web.servlet.SessionUtil
Misc utility methods for sessions and cookies.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidRemoves the test cookies if previously set.static booleanReturns true if the browser accepts cookies.static StringReturns a new session identifier.static voidSets a test cookies.
-
Constructor Details
-
SessionUtil
public SessionUtil()
-
-
Method Details
-
setTestCookie
Sets a test cookies. The user should be redirected to this or some other page after calling this method and the presence of this cookie can be checked viahasTestCookie(jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse)from that page. The lifetime of the test cookie is set to the browsers lifetime (will be lost when the browser exits). -
hasTestCookie
Returns true if the browser accepts cookies. ThesetTestCookie(HttpServletRequest, HttpServletResponse)method must have been invoked by some page prior to calling this method AND the user must have been either redirected to that or some other page AND this method must be invoked from that redirected page.Note: Test cookies are entirely self contained. They are meant to figure out if a browser accepts cookies. Their presence or absence does not mean that other cookies will not be sent by the browser. These other cookies may point to a expired session in memory or database and a seperate check for that should be made.
-
deleteTestCookie
Removes the test cookies if previously set. Normally, the test cookie set by thesetTestCookie(HttpServletRequest, HttpServletResponse)method is automatically removed when the browser exists, but this method allows removing it before such time. -
newSessionID
Returns a new session identifier.See: cookies.lcs.mit.edu See: www.across.si There are 2 issues with generating sessionid's. 1) uniqueness - 2 or more sessionid's should not end up being the same. 2) hard-to-guess - For example, sequential values like 1, 2, 3 are unique but easy to guess and therefore easy to session hijack. Our sessionid's have 2 parts: a) a timestamp for guaranteed uniqueness (easy to guess) b) random data (hard to guess)
-