Rails v2.3 : Difference between session and cookies

后端 未结 4 929
野趣味
野趣味 2020-12-31 04:58

I am learning Rails by reading the online guide(for Rails v2.3). The guide is great, however, there is a confusion for me, that\'s:

there is a chapt

4条回答
  •  清歌不尽
    2020-12-31 05:52

    Sessions & Cookies both hold the ability to store some information (e.g : the current_user id) in between two or more requests which (in http) are otherwise stateless.

    But Session is more of an abstract concept related to the notion of being in a certain state for a specific amount of time : the info it contains can be stored in the database, in a server side file, in a redis hash OR in a cookie.

    Cookies are always the little text file navigators have to store some persistent data in between requests... But having some data on the client side can be insecure so that's why it is often encrypted. But it's true the notion can overlap with session.

    TL;DR : session the abstract concept of holding temporary data. Cookies one (common) way of doing it.

提交回复
热议问题