会话cookie和持久的cookie [英] Session cookies and persistent cookies

查看:717
本文介绍了会话cookie和持久的cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,会话cookie被存储在浏览器的处理(在存储器中,不是在硬盘)。当用户关闭浏览器,这个cookie被释放,我们不能再获得这个饼干。所以这种饼干是用来保存会话ID。

永久Cookie保存在硬盘上。他们还活着,直到他们过期。通常情况下,我们通过设定一个到期创建此区。

所以我的疑问是:


  1. 如果我们设置cookie的没有到期时间后,这个cookie将被视为会话cookie?它将被保存在浏览器的进程?


  2. 与到期时间一个cookie必须被视为永久性的Cookie?我们可以设置一个cookie 与到期时间存储在浏览器的过程吗?


  3. 我们可以使会话cookie不会出现在浏览器的进程?让它停留在磁盘上?如果可以,如何code,PHP / asp.net / JAVA ??



解决方案

据我关心的,我们从服务器到客户端发回什么是存储在用户的硬盘,它的永久性的Cookie 为你调用。在会话cookie 存储在你与网站对话的一些信息,以后你清除缓存或重新启动浏览器,改变了谈话的资料。当你访问一个网站,你不发送SESSION_ID到服务器,因为你还没有一个。然后,服务器生成一个SESSION_ID并存储的谈话信息,SESSION_ID在服务器端的键值对,并返回到SESSION_ID客户端,这在存储永久性Cookie 。这就是我眼中的过程。

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

解决方案

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.

这篇关于会话cookie和持久的cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆