Session cookies and persistent cookies

懵懂的女人 提交于 2019-12-07 12:10:58

问题


As I know, session cookies are stored in the browser's process (in memory, not in hard disk). When user close the browser, this cookies are released, we can't get this cookies again. So this kind of cookies are used to save session id.

Persistent cookies are saved on hard disk. They are alive until they are expired. Usually, we create this cookies by setting an expiration.

So my doubt is that:

  1. If we set a cookie without an expiration time, this cookie will be treated as session cookie? It will be saved in the browser's process?

  2. A cookie with expiration time must be treated as persistent cookie? Can we set a cookie with a expiration time stored in browser's process?

  3. Can we make the session cookies not to appear in the browser's process? Let it stay on the disk? If it can, how to code, php/asp.net/java ??


回答1:


as far as I concerned, what we send back from server to client is stored in user's hard disk, it's persistent cookie as you called. the session cookie stores some information on a conversation you make with websites, after you clear cache or restart your browser, the conversation information changed. When you visit a website, you don't send a session_id to the server because you don't have one yet. The server then generates a session_id and stores conversation information, session_id as key-value pair in server side, and return the session_id to client side, which stores in persistent cookies. This is the process in my eyes.



来源:https://stackoverflow.com/questions/15468845/session-cookies-and-persistent-cookies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!