Click here to Skip to main content
15,035,685 members
Please Sign up or sign in to vote.
1.36/5 (3 votes)
See more:
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?
Posted
Updated 2-Jul-13 20:49pm
v2

   
Comments
Tanumay99 3-Jul-13 3:14am
   
thank you.
It really help to under stand.
jaideepsinh 3-Jul-13 3:36am
   
Thank's Tanumay for accepting as answer.
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:
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900