yu kong
yu kong

Reputation: 13

How to configure Spring-sesssion Custom Cookie by xml

sorry for my poor english, my current config like this:

<bean class="org.springframework.session.web.http.DefaultCookieSerializer">
    <property name="cookieName" value="test_sessionid"></property>
    <property name="cookiePath" value="/"></property>
    <!-- <property name="domainName" value="example.com"></property> -->
    <property name="domainNamePattern" value="^.+?\\.(\\w+\\.[a-z]+)$"></property>
</bean>

i want to custom a domain,it is working well while i configured the domainName property.but when i configure the domainNamePattern as above,it just working on localhost and ip address,but no www.example.com test.example.com tks.

Upvotes: 1

Views: 2095

Answers (1)

Rob Winch
Rob Winch

Reputation: 21720

It looks like you are not using a valid Regular Expression (the expression is escaped for Java String but you are using XML). The expression will not match any of the domains so it will always use the current domain. Try the following instead:

<bean class="org.springframework.session.web.http.DefaultCookieSerializer">
    <property name="cookieName" value="test_sessionid"></property>
    <property name="cookiePath" value="/"></property>
    <!-- <property name="domainName" value="example.com"></property> -->
    <property name="domainNamePattern" value="^.+?\.(\w+\.[a-z]+)$"></property>
</bean>

Upvotes: 3

Related Questions