*/
public HttpSessionImpl getSession(final HttpServerExchange exchange, boolean create) {
final SessionCookieConfigImpl c = getSessionCookieConfig();
HttpSessionImpl httpSession = exchange.getAttachment(sessionAttachmentKey);
if (httpSession == null) {
final SessionManager sessionManager = deploymentInfo.getSessionManager();
Session session = c.getAttachedSession(exchange);
if (session == null) {
session = sessionManager.getSession(exchange, c);
}
if (session != null) {
httpSession = new HttpSessionImpl(session, this, getDeployment().getApplicationListeners(), exchange, false);
exchange.putAttachment(sessionAttachmentKey, httpSession);
} else if (create) {
final Session newSession = sessionManager.createSession(exchange, c);
httpSession = new HttpSessionImpl(newSession, this, getDeployment().getApplicationListeners(), exchange, true);
exchange.putAttachment(sessionAttachmentKey, httpSession);
getDeployment().getApplicationListeners().sessionCreated(httpSession);
}
}