How to maintain user sessions in DropWizard?

I am looking for a persistent session manager that saves a session in a file system (e.g. PHP) that can be used with DropWizard. I see that there is one Environment.getSessionHandler() , but I do not see the documentation on it.

I could write my own, but I hope for cooked food. Will the above SessionHandler be what I'm looking for? And how to use it?

+8
session dropwizard
source share
3 answers

With dropwizard> 0.7

 environment.jersey().register(HttpSessionProvider.class); environment.servlets().setSessionHandler(new SessionHandler()); 

And then use @Session annotation in your resource classes.

+5
source share

DropWizard does not support sessions out of the box and based on author posts in google groups, they also do not plan to support it in the future.

The only way now is to implement you org.eclipse.jetty.server.session.SessionHandler yourself or look for something that already exists and then call environment.setSessionHandler(...)

And if you need this information, DW 0.6.2 uses Jetty 8.1.10

You can also check out http://cosmo-opticon.net/blog/2013/1/23/session-based-security-in-dropwizard and see if you can reuse some of them.

+2
source share

REST is, by definition, stateless, so sessions should not be used at all. The same URI should always return the same results regardless of session state.

-2
source share

All Articles