Click here to Skip to main content
12,748,323 members (41,569 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET
Hi i am a new developer to .net
Posted 28-Jul-12 8:34am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Hi ,
Difference between cookies and sessions
Cookies a piece of data stored in the user's browser it can use on store Username & Password so user do not have to re-login to your website every time they visit , Cookies can keep information in the user's browser until deleted or Expired
Sessions allowing access and passing information while the user has their browser open .
Problem of Cookies Some browser not supporting Cookies or it disable by user
Session More session more wast resource in your sever and it may crash
Best Regards
panduu 29-Jul-12 0:48am
Thank u for giving the differece exactly
Mohamed Mitwalli 29-Jul-12 2:09am
your welcome :)
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

My rule is:

1) If you can, use a URL paramater to store state, because it provides the most predictable and scalable 'web behavior'
2) ..if that's not suitable, use a URL-based session, because it provides more predictable web behavior than cookie-sessions
3) ..if that's not suitable, use a cookie, because it scales easily
4) ..if that's not suitable, use a cookie based session, because, well.. nothing else worked

A cookie is stored by the client browser and sent back from the client to the server each time it requests a webpage fro the same cookie domain (normally the same server name or domain). A cookie can be set to live a short time, or a very long time (including forever).

A Session is server-side storage, which is generally stored in ram or on-disk on your server. Each time the same client comes back to the server, the server-side session storage is loaded/available. A unique URL paramater or cookie must be used to identify the client, so you can find his server-side session state.

Cookies are easier to scale across multiple web servers, because the client stores and re-produces the cookie each request, regardless of which server they are sent to in a load-balanced situation. Server-affinity load balancing can remedy this to a degree, but has it's own set of drawbacks. Sessions also usually impact server performance more, because the servers have to handle every session, wheras with cookies this work is offloaded to each client for himself.

Server Sessions are much more suitable for large result sets, as they don't need to be sent back and forth between the client and server each request.

In some situations, neither Sessions nor Cookies are a good answer, and URL paramaters or other methods are a better choice. In the web, we expect to be able to launch multiple browsers on the same website, and click "back" and "forward" often. Using Cookies or Sessions to store application state can create problems where the same operation can't be performed in two separate browser windows. In this case a URL paramater based state-mechanism may be more appropriate.

Hope that quick overview helped. Read the wikipedia pages on Session and Cookie for more information.
panduu 29-Jul-12 0:48am
Thank u

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170215.1 | Last Updated 28 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100