本文整理匯總了Java中javax.servlet.SessionCookieConfig.setMaxAge方法的典型用法代碼示例。如果您正苦於以下問題:Java SessionCookieConfig.setMaxAge方法的具體用法?Java SessionCookieConfig.setMaxAge怎麽用?Java SessionCookieConfig.setMaxAge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.servlet.SessionCookieConfig
的用法示例。
在下文中一共展示了SessionCookieConfig.setMaxAge方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: configureSessionCookie
import javax.servlet.SessionCookieConfig; //導入方法依賴的package包/類
private void configureSessionCookie(SessionCookieConfig config) {
Cookie cookie = this.session.getCookie();
if (cookie.getName() != null) {
config.setName(cookie.getName());
}
if (cookie.getDomain() != null) {
config.setDomain(cookie.getDomain());
}
if (cookie.getPath() != null) {
config.setPath(cookie.getPath());
}
if (cookie.getComment() != null) {
config.setComment(cookie.getComment());
}
if (cookie.getHttpOnly() != null) {
config.setHttpOnly(cookie.getHttpOnly());
}
if (cookie.getSecure() != null) {
config.setSecure(cookie.getSecure());
}
if (cookie.getMaxAge() != null) {
config.setMaxAge(cookie.getMaxAge());
}
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:25,代碼來源:ServerProperties.java
示例2: configure
import javax.servlet.SessionCookieConfig; //導入方法依賴的package包/類
/**
* Configures the cookies 🍪
*
* @param config cookie configuration
* @param cookieName the name of the cookies
* @see SessionCookieConfig#setName(String)
* @see SessionCookieConfig#setMaxAge(int)
*/
public static void configure(SessionCookieConfig config, String cookieName) {
// Change the name of the cookie
config.setName(cookieName);
// Change the lifetime of the cookie session: it should not be greater than the lifetime of the JWT tokens
String expiration = QfsProperties.loadProperties("jwt.properties").getProperty(JwtConfig.EXPIRATION_PROPERTY);
int maxAge = null != expiration ? Integer.parseInt(expiration): JwtConfig.DEFAULT_EXPIRATION;
config.setMaxAge(maxAge);
}
示例3: setSessionConfig
import javax.servlet.SessionCookieConfig; //導入方法依賴的package包/類
@Override
public void setSessionConfig() {
SessionManager sessionManager = webAppContext.getSessionHandler().getSessionManager();
SessionCookieConfig sessionCookieConfig = sessionManager.getSessionCookieConfig();
sessionCookieConfig.setHttpOnly(true);
sessionCookieConfig.setSecure(systemEnvironment.isSessionCookieSecure());
sessionCookieConfig.setMaxAge(systemEnvironment.sessionCookieMaxAgeInSeconds());
sessionManager.setMaxInactiveInterval(systemEnvironment.sessionTimeoutInSeconds());
}