以编程方式设置Jetty会话cookie名称 [英] Set Jetty session cookie name programmatically

查看:174
本文介绍了以编程方式设置Jetty会话cookie名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此问题,如何通过Jetty 8中的代码设置会话cookie名称?

I'm running in this issue, how can I set session cookie name by code in Jetty 8?

ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
sessionHandler = new SessionHandler();
sessionHandler.getSessionManager().setSessionCookie("JSESSIONID_"+runningPort);
context.setSessionHandler(sessionHandler);

错误,在Jetty8 SessionManager setSessionCookie(String)已删除。

Is wrong, in Jetty8 SessionManager setSessionCookie(String) was removed.

推荐答案

以下是答案:

ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
SessionManager sm = new HashSessionManager();
((HashSessionManager)sm).setSessionCookie("JSESSIONID_"+activity.WEB_SERVER_PORT);
context.setSessionHandler(new SessionHandler(sm));

这篇关于以编程方式设置Jetty会话cookie名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆