views:

55

answers:

4

You see the code below, how I did use the session variable; So the three questions are:

  1. Where are they stored? (Server or Client side)
  2. Are they unique for each web page visitor?
  3. Can I remove it using ajax or simple js code when my job is done with it? or it will be removed automatically..?

.

sbyte[][] arrImages = svc.getImagesForFields(new String[] { "CustomerName", "CustomerSurName" });

Dictionary<string, byte[]> smartImageData = new Dictionary<string, byte[]>();
int i = 0;
foreach (sbyte[] bytes in arrImages)
{
    smartImageData.Add(fieldNames[i], ConvertToByte(bytes));
    i++;
}

Session.Add("SmartImageData", smartImageData);
A: 

Session variable are stored on the Server? You can configure other state management mechanism (E.g Database).

They are unique for each user session. It will be removed when Session times out.

Amitabh
+2  A: 

Read more about sessions here. To answer your questions:

  1. Depends on your configuration (in-process, Session State Server etc.), but always server-side.
  2. Yes, each visitor gets a unique cookie.
  3. You can remove it client-side by removing the session cookie (usually ASP.NET_SessionId), or server-side by calling Session.Abandon(). Also, a session times out after a certain (configurable) period of inactivity.
ErikHeemskerk
" ASP.NET_SessionId " could you please make this clear?
blgnklc
The cookie on the client that's used to identify the user's session is called ASP.NET_SessionId.
ErikHeemskerk
A: 

Session state information is stored on the server and not on the client side. When the session expires, this session information is removed completely and automatically. You can change the session expiration duration through web.config file. Session data is unique for each user. You can always use it using ajax or change it or even remove it.

If you want the session data persistent to be persistent, you can configure your database for storing the session information. You can even configure a state server to store the session data.

mohang
A: 

The session is usually stored on the server (depending on your server/application configuration). Each unique browser connection is allocated a session id which the server uses to associate the client with a unique server session on subsequent connections. The session id is passed to the client to store as either a cookie, or as a paramater attached to each url request to the server.

It is used as a means of preserving client state with the server between HTTP calls.

The session expires after a configurable time of inactivity. However in .NET you can call Session.Abandon() to end the current session.

Adrian Regan