cookie和会话之间有什么关系? [英] what is the relation between cookies and session?

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

问题描述

Cookie与会话之间的关系是什么?

我们知道Cookie用于客户端状态管理,会话用于< b>服务器端状态管理..

它们之间是否有任何关系?

解决方案

在这里你可以看到两者之间的关系:

https://devcentral.f5.com/blogs/us/sessions-and-cookies-and-persistence-oh-my#.UdPNRGfYhOY [ ^ ]


会话存储在服务器上,不依赖于客户端浏览器中启用的cookie。会话是Web开发人员存储他们可能希望在请求中使用的一些应用程序相关数据的地方。

Cookies 在客户端(浏览器)上存储数据位并通过通过HTTP标头Cookie到服务器。



如果没有持久性,用户会在负载均衡的环境中不知不觉地在多个Web服务器上创建会话。这是浪费资源,因为会话将保留在Web服务器的内存中,直到它们根据Web服务器的配置超时。此外,缺乏持久性会破坏Web应用程序,因为服务器2上不再可以访问先前请求中存储在会话中的数据,因为它仍然位于服务器1上。



这就是为什么负载平衡或应用程序交付解决方案能够处理基于持久性的负载分配非常重要的原因。如果您的负载平衡解决方案基于行业标准算法(如循环法,最小连接或两者的加权版本)工作,那么您可能会破坏那些需要持久性的应用程序,因为负载平衡算法没有采用会话持久性需要考虑。


这两个在第一个地方没有关系



请参阅以下链接,了解其工作原理。



Cookie和会话之间的区别 [ ^ ]



Cookie vs会话哪个最好,为什么? [ ^ ]



了解Cookie和会话 [ ^ ]



用于什么会话cookie [ ^ ]



问候......:笑:

what is the relation between cookies and session?
We know cookies is use for client side state management and session is use for server side state management..
Is there any relation between them?

解决方案

Here you can see the relation between both:
https://devcentral.f5.com/blogs/us/sessions-and-cookies-and-persistence-oh-my#.UdPNRGfYhOY[^]


Sessions are stored on the server, and are not reliant on cookies being enable in the client's browser. Sessions are where web developers store bits of application relevant data that they may wish to use across requests.
Cookies store bits of data on the client (the browser) and are passed to the server via the HTTP header Cookie.

Without persistence, users would be unknowingly creating sessions willy-nilly across multiple web servers in a load-balanced environment. That's a waste of resources, as sessions will remain in memory on the web server until they time out according to the web server's configuration. Additionally, a lack of persistence breaks web applications, because the data stored in the session on previous requests is no longer accessible on Server 2 because it's still sitting over on Server 1.

This is why it's so important that a load-balancing or application delivery solution is capable of handling persistence-based load distribution. If your load-balancing solution works based on an industry standard algorithm like round-robin, least-connections, or a weighted version of either, then you're likely to break those applications which require persistence because the load balancing algorithms aren't taking session persistence needs into consideration.


Theres no relation between these two at the first place

Refer to below links to have complete idea how that works.

The Difference Between Cookies and Sessions[^]

Cookie vs session which is best and why?[^]

Understanding Cookies and Sessions[^]

What are session cookies used for?[^]

Regards.. :laugh:


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

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