2016-11-07 3 views
1

私は奇妙な問題があり、修正できません。ブラウザでSpringアプリケーションのログアウトを避ける

問題:

私はブラウザを終了してから再度開くたび、長いセッションタイムアウトを持っている私の春のWebアプリケーションにログインするには、私のWebアプリにアクセスして、私は、ログインページのすべての時間を参照してください。

ブラウザが閉じていない限り正常に動作します。私はクロムの設定にいくつかの問題があると思ったが、そうではない。また、すべてのブラウザで発生します。

マイweb.xml

<session-config> 
     <session-timeout>10000</session-timeout> 
     <cookie-config> 
      <name>myapp</name> 
      <http-only>true</http-only> 
     </cookie-config> 
     <tracking-mode>COOKIE</tracking-mode> 
    </session-config> 

私の春のセキュリティ設定:

<security:http auto-config="true" use-expressions="true"> 
     <security:intercept-url pattern="/resources/**" access="permitAll" /> 
     <security:intercept-url pattern="/login" access="permitAll" /> 
     <security:intercept-url pattern="/login/forgot" access="permitAll" /> 
     <security:intercept-url pattern="/login/resetpassword" access="permitAll" /> 
     <security:intercept-url pattern="/home/admin/**" access="hasAnyRole('ROLE_admin', 'ROLE_manager')" /> 
     <security:intercept-url pattern="/**" access="hasAnyRole('ROLE_admin', 'ROLE_manager','ROLE_user')" /> 
     <security:form-login 
      login-page="/login" 
      login-processing-url="/login" 
      authentication-failure-handler-ref="authenticationFailureFilter" 
      authentication-success-handler-ref="authenticationSuccessHandler" 
      username-parameter="email" 
      password-parameter="password" /> 
     <!-- enable csrf protection --> 
     <security:csrf/> 

    </security:http> 

web.xmlやSpringセキュリティに問題はありませんか?

+1

javax.http.servlet.cookieクラス最高年齢の属性を確認し、デフォルト値は-1、ブラウザがシャットダウンされた場合にクッキーを削除しています。 – notionquest

+0

@notionquestええ問題を解決しました – Shadow

+0

答えを追加しました。それが有用だった場合は受け入れてください。ありがとう! – notionquest

答えて

3

クッキーの最大有効期間属性を設定してください。デフォルトでは

、-1クッキーは は、ブラウザがシャットダウンされるまで存続することを示しており、返されます。

Http Servlet Cookie Max Age

関連する問題