java - web项目中,用户登陆信息存储在session中好 还是cookie中好,取决于什么?
PHPz
PHPz 2017-04-18 10:50:04
0
3
717

web项目中,用户登陆信息存储在session中好 还是cookie中好,取决于什么?

PHPz
PHPz

学习是最好的投资!

reply all (3)
伊谢尔伦

First of all, you must understand that the session is stored on the server side and the cookie is stored on the client side. It is wrong to ask this~
The server needs to store login information, and the client browser also needs it~ By the way~ General browser cookies The settings are turned on. If your cookie settings are turned off, you will not be able to log in to some websites, such as logging in to your Baidu account. If you turn off cookies, Baidu will prompt you to turn on cookies and not allow you to log in. If you don’t believe me, you can try PS (turning cookies off will work) URL rewriting technology is used, but for security reasons most websites do not use this technology now) In a word: cookie is an identifier given to the client by the server. Session is used to store the information of the currently logged in user (generally large websites use redis to specifically manage sessions) [ Sessions and cookies all have life cycles. When the server-side session life cycle ends, the client needs to log in again! There are also some cookies whose life cycle ends when the browser is closed]
Finally: (There is a lot of other knowledge that I have not mentioned. I hope the author can learn more about JavaWeb's related technologies about session and cookies)

    黄舟

    Put it in memcache or redis

      Peter_Zhu

      Scale of the project
      A personal small project session is enough.
      If the project is very large, I don’t know.
      If it is the server of ios android web. Under normal circumstances, the user will be given a token after logging in. User operations need to carry tokens for verification.

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!