Chapter 6. Session Management: Conversational state Flashcards
How do you start a session with the client?
request.getSession() – Container handles all the rest.
How can you determine if the session you got is brand new for this client?
session.isNew();
How would you get ONLY a pre-existing session, AKA don’t create new but get it if it already exists?
request.getSession(false);
How would you terminate a session with a client?
session.invalidate();
How would you configure the session timeout in the Deployment Descriptor?
session-config, and under that session-timeout.
How would you configure the timeout for a sessinon on a particular session?
session.setMaxInactiveInterval(TimeInSeconds);
How do you create, set an expiration time, and send a cookie to the client?
new Cookie(“name”, value);
cookie. setMaxAge(secondsToExpire) – Also -1 to expire on browser restart.
response. addCookie(cookie)
How do you find a Cookie from a request?
There is no way to get a particular cookie, we need to get them all and loop to find the one we need.