Renaming JSESSIONID

房东的猫 提交于 2019-12-13 04:05:12

问题


I tried to rename JSESSIONID as below in web.xml, but seems like sometimes I do see the default name in the logs(I am logging in a filter in case default name is given), any idea?, I am using spring 3.2.18 and servlet-api-3.1

<session-config>
    <session-timeout>45</session-timeout>
    <cookie-config>
      <path>/</path>
      <domain>.example.com</domain>
      <name>XXX_JSESSIONID</name>
    </cookie-config>
  </session-config>

回答1:


As you are using spring-3.2.18 you should try the following code to override DefaultCookieSerializer. You can find detail information in Spring Docs

@Bean
public DefaultCookieSerializer defaultCookieSerializer(){
    DefaultCookieSerializer defaultCookieSerializer = new DefaultCookieSerializer();
    defaultCookieSerializer.setCookieName("mySessionId");
    return defaultCookieSerializer;
}


来源:https://stackoverflow.com/questions/54698948/renaming-jsessionid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!