Tomcat 中的会话 ID 长度 [英] Session Id Length in Tomcat

查看:36
本文介绍了Tomcat 中的会话 ID 长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要修改tomcat生成的session ID长度.默认情况下它是 32 字节,不幸的是我们需要 20 的会话 ID 长度.在线查看我可以看到 StandardManager 似乎管理这个扩展 PersistanceManager.

We need to change the session ID length generated by tomcat. By default it is 32 bytes, unfortunately we need a session ID length of 20. Looking online I can see the StandardManager seems to manage this which extends PersistanceManager.

有谁知道 sessionIdLength 是否可以在 tomcat 配置中修改?如果是,是什么文件?

Does anyone know if the sessionIdLength can be modified in the tomcat config? If so what files?

另一种方法是创建一个自定义的 Manager,它只是覆盖/设置 sessionidLength.这可能吗?你如何告诉 tomcat 在配置中使用自定义管理器?

An alternative would be to create a custom Manager which simply overrides/sets the sessionidLength. Is this possible? How do you tell tomcat to use the custom manager in the config?

推荐答案

是的,您可以通过配置文件修改 StandardManager.Manager 元素可以嵌套在任何上下文中.

Yes, you can modify the StandardManager via config file. The Manager element can be nested inside any Context.

因此,修改具有您的上下文的任何配置文件.它可能是位于 conf 目录中的 server.xml.或者位于 war 文件 META-INF 目录中的 context.xml.

So, modify whichever config file has your Context. It might be the server.xml located in the conf directory. Or a context.xml located in the META-INF directory of your war file.

要为整个服务器提供默认值,请编辑您的 $CATALINA_HOME/conf/context.xml.取消对 Manager 行的注释,并添加 sessionIdLength 属性.

To provide a default for the entire server, edit your $CATALINA_HOME/conf/context.xml. Uncomment the Manager line, and add the sessionIdLength attribute.

<Manager sessionIdLength="10" />

这篇关于Tomcat 中的会话 ID 长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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