Rails Login Reset Session

后端 未结 4 1255
难免孤独
难免孤独 2021-02-02 13:00

Is it best practice to call reset_session when a user successfully signs in and to call it again when a user signs out? Are there any side effects/problems to doing this?

4条回答
  •  逝去的感伤
    2021-02-02 13:55

    I consider it good practice to reset the session when a user logs in. That way, malicious individuals can't sniff out their session cookie before a client's connection is encrypted and still use it after they use the sign in form over https. Try:

    temp = session
    reset_session
    session.reverse_merge!(temp)
    

    This way, session gets the new values generated by reset_session, but any other session variables remain intact.

提交回复
热议问题