Java Code Examples for org.springframework.session.web.http.DefaultCookieSerializer#setCookieName()

The following examples show how to use org.springframework.session.web.http.DefaultCookieSerializer#setCookieName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FixSpringSessionCookieSerializerConfiguration.java    From onetwo with Apache License 2.0 5 votes vote down vote up
@Bean
	@ConditionalOnMissingBean(CookieSerializer.class)
	public CookieSerializer cookieSerializer(){
		DefaultCookieSerializer serializer = new DefaultCookieSerializer();
		CookieConfig cookieConfig = securityConfig.getCookie();
//		if(StringUtils.isNotBlank(cookieConfig.getPath())){
		serializer.setCookiePath(cookieConfig.getPath());
//		}
		if(StringUtils.isNotBlank(cookieConfig.getDomain())){
			serializer.setDomainName(cookieConfig.getDomain());
		}
		serializer.setCookieName(cookieConfig.getName());
		return serializer;
	}
 
Example 2
Source File: Config.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Bean
public CookieSerializer cookieSerializer() {
	DefaultCookieSerializer serializer = new DefaultCookieSerializer();
	serializer.setCookieName("JSESSIONID"); // <1>
	serializer.setCookiePath("/"); // <2>
	serializer.setDomainNamePattern("^.+?\\.(\\w+\\.[a-z]+)$"); // <3>
	return serializer;
}
 
Example 3
Source File: SpringHttpSessionConfiguration.java    From spring-session with Apache License 2.0 5 votes vote down vote up
private CookieSerializer createDefaultCookieSerializer() {
	DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer();
	if (this.servletContext != null) {
		SessionCookieConfig sessionCookieConfig = null;
		try {
			sessionCookieConfig = this.servletContext.getSessionCookieConfig();
		}
		catch (UnsupportedOperationException ex) {
			this.logger.warn("Unable to obtain SessionCookieConfig: " + ex.getMessage());
		}
		if (sessionCookieConfig != null) {
			if (sessionCookieConfig.getName() != null) {
				cookieSerializer.setCookieName(sessionCookieConfig.getName());
			}
			if (sessionCookieConfig.getDomain() != null) {
				cookieSerializer.setDomainName(sessionCookieConfig.getDomain());
			}
			if (sessionCookieConfig.getPath() != null) {
				cookieSerializer.setCookiePath(sessionCookieConfig.getPath());
			}
			if (sessionCookieConfig.getMaxAge() != -1) {
				cookieSerializer.setCookieMaxAge(sessionCookieConfig.getMaxAge());
			}
		}
	}
	if (this.usesSpringSessionRememberMeServices) {
		cookieSerializer.setRememberMeRequestAttribute(SpringSessionRememberMeServices.REMEMBER_ME_LOGIN_ATTR);
	}
	return cookieSerializer;
}
 
Example 4
Source File: SessionConfig.java    From retro-game with GNU Affero General Public License v3.0 4 votes vote down vote up
@Bean
public CookieSerializer cookieSerializer() {
  DefaultCookieSerializer serializer = new DefaultCookieSerializer();
  serializer.setCookieName("s");
  return serializer;
}