Permalink
Browse files

Set default cookie session tracking name to molecule.session

  • Loading branch information...
testinfected committed Oct 9, 2015
1 parent 345f332 commit b4143a0d15023c4fc259678e2f15698c77f3a76f
@@ -9,11 +9,11 @@
public class CookieSessionTracker extends AbstractMiddleware {
- private static final String STANDARD_SERVLET_SESSION_COOKIE = "JSESSIONID";
+ public static final String STANDARD_SERVLET_SESSION_COOKIE = "JSESSIONID";
private final SessionStore store;
- private String name = STANDARD_SERVLET_SESSION_COOKIE;
+ private String name = "molecule.session";
private int expireAfter = -1;
public CookieSessionTracker(SessionStore store) {
@@ -30,7 +30,7 @@
SessionStore store = context.mock(SessionStore.class);
int timeout = (int) TimeUnit.MINUTES.toSeconds(30);
- String SESSION_COOKIE = "molecule.session";
+ String SESSION_COOKIE = CookieSessionTracker.STANDARD_SERVLET_SESSION_COOKIE;
CookieSessionTracker tracker = new CookieSessionTracker(store).usingCookieName(SESSION_COOKIE);
Request request = new Request();
@@ -35,7 +35,8 @@ public void run(WebServer server) throws IOException {
// Enable cookie support
server.add(new Cookies())
// Track sessions using transient - a.k.a session - cookies by default
- .add(new CookieSessionTracker(sessionPool))
+ // You decide of the cookie name to track sessions
+ .add(new CookieSessionTracker(sessionPool).usingCookieName("molecule.session"))
.start(new DynamicRoutes() {{
map("/").to((request, response) -> {
Session session = Session.get(request);
@@ -26,7 +26,8 @@
WebServer server = WebServer.create(9999);
Throwable error;
- String SESSION_COOKIE = "JSESSIONID"; // The default session cookie name is the standard servlet cookie
+ // The default session cookie name, it can be set to something different
+ String SESSION_COOKIE = "molecule.session";
int FIVE_MIN = 300;
HttpRequest request = new HttpRequest(9999);

0 comments on commit b4143a0

Please sign in to comment.