Cookies VS. SessionState

  • Thread starter Thread starter Adam
  • Start date Start date
A

Adam

Well guys some might consider this a silly topic but i just want to get
the general consensus on the matter.
So i ask the question "Which is more efficient to use Cookies or
SessionState Variables ?".
I'm just looking for opinions so please don’t flame me.

- Adam
 
They are not mutually exclusive. In fact, if you use session state,
then by default you are also using cookies. Once an ASP.NET session
starts, the server will send a cookie to the client to associate
him/her with the newly created session.

I find it more productive to think in terms of session state and view
state, and simply consider cookies an implementation detail handled by
the runtime.
 
Adam said:
Well guys some might consider this a silly topic but i just want to get
the general consensus on the matter.
So i ask the question "Which is more efficient to use Cookies or
SessionState Variables ?".
I'm just looking for opinions so please don’t flame me.

- Adam

Depends on how you want to use them:

Cookies:
- browser sends them on every request: you don't want too much data there
- are stored on the user's computer
- pro: no timeout (if you want)
- con: user can read and/or delete them
- needs serializing to string

Session:
- Stored on the server (by default in-memory, other options exist)
- You can use larger structures (but don't overdo it)
- you can store references to classes, no need to serialize (if InProc)
- times out after a while (20 minutes by default)
- users can't access/modify them
 
Back
Top