Click here to Skip to main content
15,887,822 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
What is the difference b/w session and coookies?
Posted
Updated 30-Sep-11 3:00am
v2

Sessions1. are stored per-user in memory(or an alternative Session-State) on the server. Sessions use a cookie(session key) to tie the user to the session. This means no "sensitive" data is stored in the cookie on the users machine.

2. Session can store any type of data because the
value is of datatype of "object"
3.we cannot disable the sessions.Sessions can be used
without cookies also(by disabling cookies)
4. The disadvantage of session is that it is a
burden/overhead on server
5. Sessions are called as Non-Persistent cookies
because its life time can be set manually



Cookies 1. are stored per-user on the users machine. A cookie is usually just a bit of information. Cookies are usually used for simple user settings colours preferences ect. No sensitive information should ever be stored in a cookie.

2. Cookies can store only "string" datatype
3. We can disable cookies
4.Since the value is string there is no security
5. We have persistent and non-persistent cookies

 
Share this answer
 
A session is the lifecycle of a users interaction of a site from 1st page load through to when they log out or are inactive for session_timeout duration. Typically this is server side references.

Cookies are small files that are stored at the client side which contain data that could be used to remember user preferences, shopping basket contents session_tokens etc., the cookie lifecycle is determined by when cookie expiry date or if the user deletes these cookies via the browser or some other mechanism.
 
Share this answer
 
Comments
Manfred Rudolf Bihy 30-Sep-11 9:03am    
Shrt nd cncse! 5+
Session varaibles are server objects and saved at server memory and Cookies are smal files,used to store user's data and save at client' system.Also we have alot of flexiblity using Session while cookies are limited and also depends on browsers.

There are a lot more things,for details have a look to the following link.
Beginner's Guide To ASP.NET Cookies

Exploring Session in ASP.Net
 
Share this answer
 

Cookie


Session


Cookies gets stored in clients Browser and stays until we delete cookies,


So cookies can be taken in use even after client browser closing. Say
for example if we store user's login details in cookies then once user logs in,
it gets stored in cookies and later after each time uses visits the site it
will retain logged in as it was.


While Session is we can
say temporary storage, like if we do want to keep anonymous user's shopping
cart throughout user's surfing until user’s closes browser. Session will not
retain longer after browser closing.


User can block cookies from the browser settings


Session cannot be blocked from browser


Cookies doesn’t have Time Out


Sessions are having time out that can be set from code


Cookies can be removed manually by user


User cannot kill session manually


Cookies retains forever until user clears from browser


Sessions stays only for the time user stays on website


Cookies get stored in clients browser


In asp.net there are options for session state where we can mention
how session to be stored/managed by asp.net.


e.g.


HTML
<sessionState
  mode="SQLServer"
  cookieless="true"
   regenerateExpiredSessionId="true
  "
 timeout="30"
   sqlConnectionString="Data Source=MySqlServer;Integrated Security=SSPI;"
& nbsp;stateNetworkTimeout="30"/>


 
Share this answer
 
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