Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Session cookies and persistent cookies

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 ??

like image 278
roast_soul Avatar asked Nov 12 '22 09:11

roast_soul


1 Answers

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.

like image 181
Judking Avatar answered Nov 14 '22 21:11

Judking