Go to your project settings, select the 'custom' tab and create a new setting with name PersistentSessions and value true. That should do the trick.
If you don't want to do that, you can still grab the session object from the context object in a Java action.
this.getContext().getSession().getId();