ASP.NET session management using SQL SERVER

A

Abhilash.k.m

This is regarding the session management using Out of
proc session management(SQL SERVER). Among the samples
below which one is better to set the session?



1. There are 20 session variables and all of them
are being stored into session and accessed from session
and individual session object. Example: Session["a"]
= "XYZ", Session["b"]=100, Session["c"]="NAME", etc.
where values are of primitive data type or immediate
derivative of the primitive data types.

2. There are 20 session variable, a custom object is
created out of them. The custom object is stored into the
session. Example: NameValueCollection is an object where
data will be stored as NameValueCollection["a"] = "XYZ",
NameValueCollection["b"]=100, NameValueCollection["c"]
="NAME". Finally while storing it in the session the
NameValueCollection is used as Session["DATA"]=
NameValueCollection.

3)Is there any performance issue due to session
management through SQL SERVER provided by DOTNET framework
 
F

Frank Drebin

Some people would disagree, but for the past few years - I pretty much
consider a SQL server an immediate part of my application. If you have a
local, semi-robust SQL server - then making calls (like storing session
information) is pretty negligable..

So, I would say - you should have a SessionID - write that out as a cookie
to the client.. then in a database, you have a SessionID that relates to
whatever session data that you need...

Same with traditional ASP - "Session" variables are really a bad idea. Even
if you are not on a cluster/server farm now - at some point you will, and
that is going to jam up your whole way of dealing with session data. The
Session object stores things on the local server. So in a server farm
scenario.. you go to the alias name, and are connected to server1, session
variables are saved - ON server1. Then you click a link, go to the alias -
and THIS time you go to server2. When it goes to process your request, it
can't - because it's not the server where your session data exists... So,
imho - it's just better to stay away from those and adopt a system that runs
on everything, and even runs when you get into a scenario when you need
highly-available servers...

hth
 
A

Abhilash.K.M

I will elaborate my requirments

We are developing a mobile web application using ASP.NET
in a web farm & not planning to use cookies as some
device browser doesn't support the same.So we are doing
the session management with the dot frame work provided
session management using sql server with the values
entered in WEB.CONFIG file.
Now we need to set some 20 values to the session .so my
question is whether we need to add individually as
session values or store all the 20 values as key value
pair(say collections).So which is better 1 0r 2?

1. There are 20 session variables and all of them
are being stored into session and accessed from session
and individual session object. Example: Session["a"]
= "XYZ", Session["b"]=100, Session["c"]="NAME", etc.
where values are of primitive data type or immediate
derivative of the primitive data types.

2. There are 20 session variable, a custom object is
created out of them. The custom object is stored into the
session. Example: NameValueCollection is an object where
data will be stored as NameValueCollection["a"] = "XYZ",
NameValueCollection["b"]=100, NameValueCollection["c"]
="NAME". Finally while storing it in the session the
NameValueCollection is used as Session["DATA"]=
NameValueCollection.

-----Original Message-----
Some people would disagree, but for the past few years - I pretty much
consider a SQL server an immediate part of my application. If you have a
local, semi-robust SQL server - then making calls (like storing session
information) is pretty negligable..

So, I would say - you should have a SessionID - write that out as a cookie
to the client.. then in a database, you have a SessionID that relates to
whatever session data that you need...

Same with traditional ASP - "Session" variables are really a bad idea. Even
if you are not on a cluster/server farm now - at some point you will, and
that is going to jam up your whole way of dealing with session data. The
Session object stores things on the local server. So in a server farm
scenario.. you go to the alias name, and are connected to server1, session
variables are saved - ON server1. Then you click a link, go to the alias -
and THIS time you go to server2. When it goes to process your request, it
can't - because it's not the server where your session data exists... So,
imho - it's just better to stay away from those and adopt a system that runs
on everything, and even runs when you get into a scenario when you need
highly-available servers...

hth

This is regarding the session management using Out of
proc session management(SQL SERVER). Among the samples
below which one is better to set the session?



1. There are 20 session variables and all of them
are being stored into session and accessed from session
and individual session object. Example: Session["a"]
= "XYZ", Session["b"]=100, Session["c"]="NAME", etc.
where values are of primitive data type or immediate
derivative of the primitive data types.

2. There are 20 session variable, a custom object is
created out of them. The custom object is stored into the
session. Example: NameValueCollection is an object where
data will be stored as NameValueCollection["a"] = "XYZ",
NameValueCollection["b"]=100, NameValueCollection["c"]
="NAME". Finally while storing it in the session the
NameValueCollection is used as Session["DATA"]=
NameValueCollection.

3)Is there any performance issue due to session
management through SQL SERVER provided by DOTNET framework


.
 
F

Frank Drebin

In that case, I'd say a collection or an array would be ideal - because you
can easily iterate through the elements..

Abhilash.K.M said:
I will elaborate my requirments

We are developing a mobile web application using ASP.NET
in a web farm & not planning to use cookies as some
device browser doesn't support the same.So we are doing
the session management with the dot frame work provided
session management using sql server with the values
entered in WEB.CONFIG file.
Now we need to set some 20 values to the session .so my
question is whether we need to add individually as
session values or store all the 20 values as key value
pair(say collections).So which is better 1 0r 2?

1. There are 20 session variables and all of them
are being stored into session and accessed from session
and individual session object. Example: Session["a"]
= "XYZ", Session["b"]=100, Session["c"]="NAME", etc.
where values are of primitive data type or immediate
derivative of the primitive data types.

2. There are 20 session variable, a custom object is
created out of them. The custom object is stored into the
session. Example: NameValueCollection is an object where
data will be stored as NameValueCollection["a"] = "XYZ",
NameValueCollection["b"]=100, NameValueCollection["c"]
="NAME". Finally while storing it in the session the
NameValueCollection is used as Session["DATA"]=
NameValueCollection.

-----Original Message-----
Some people would disagree, but for the past few years - I pretty much
consider a SQL server an immediate part of my application. If you have a
local, semi-robust SQL server - then making calls (like storing session
information) is pretty negligable..

So, I would say - you should have a SessionID - write that out as a cookie
to the client.. then in a database, you have a SessionID that relates to
whatever session data that you need...

Same with traditional ASP - "Session" variables are really a bad idea. Even
if you are not on a cluster/server farm now - at some point you will, and
that is going to jam up your whole way of dealing with session data. The
Session object stores things on the local server. So in a server farm
scenario.. you go to the alias name, and are connected to server1, session
variables are saved - ON server1. Then you click a link, go to the alias -
and THIS time you go to server2. When it goes to process your request, it
can't - because it's not the server where your session data exists... So,
imho - it's just better to stay away from those and adopt a system that runs
on everything, and even runs when you get into a scenario when you need
highly-available servers...

hth

This is regarding the session management using Out of
proc session management(SQL SERVER). Among the samples
below which one is better to set the session?



1. There are 20 session variables and all of them
are being stored into session and accessed from session
and individual session object. Example: Session["a"]
= "XYZ", Session["b"]=100, Session["c"]="NAME", etc.
where values are of primitive data type or immediate
derivative of the primitive data types.

2. There are 20 session variable, a custom object is
created out of them. The custom object is stored into the
session. Example: NameValueCollection is an object where
data will be stored as NameValueCollection["a"] = "XYZ",
NameValueCollection["b"]=100, NameValueCollection["c"]
="NAME". Finally while storing it in the session the
NameValueCollection is used as Session["DATA"]=
NameValueCollection.

3)Is there any performance issue due to session
management through SQL SERVER provided by DOTNET framework


.
 
R

Rick Spiewak

I agree. I've had good luck even using DataTables and DataSets in Session
variables.

Frank Drebin said:
In that case, I'd say a collection or an array would be ideal - because you
can easily iterate through the elements..

Abhilash.K.M said:
I will elaborate my requirments

We are developing a mobile web application using ASP.NET
in a web farm & not planning to use cookies as some
device browser doesn't support the same.So we are doing
the session management with the dot frame work provided
session management using sql server with the values
entered in WEB.CONFIG file.
Now we need to set some 20 values to the session .so my
question is whether we need to add individually as
session values or store all the 20 values as key value
pair(say collections).So which is better 1 0r 2?

1. There are 20 session variables and all of them
are being stored into session and accessed from session
and individual session object. Example: Session["a"]
= "XYZ", Session["b"]=100, Session["c"]="NAME", etc.
where values are of primitive data type or immediate
derivative of the primitive data types.

2. There are 20 session variable, a custom object is
created out of them. The custom object is stored into the
session. Example: NameValueCollection is an object where
data will be stored as NameValueCollection["a"] = "XYZ",
NameValueCollection["b"]=100, NameValueCollection["c"]
="NAME". Finally while storing it in the session the
NameValueCollection is used as Session["DATA"]=
NameValueCollection.

-----Original Message-----
Some people would disagree, but for the past few years - I pretty much
consider a SQL server an immediate part of my application. If you have a
local, semi-robust SQL server - then making calls (like storing session
information) is pretty negligable..

So, I would say - you should have a SessionID - write that out as a cookie
to the client.. then in a database, you have a SessionID that relates to
whatever session data that you need...

Same with traditional ASP - "Session" variables are really a bad idea. Even
if you are not on a cluster/server farm now - at some point you will, and
that is going to jam up your whole way of dealing with session data. The
Session object stores things on the local server. So in a server farm
scenario.. you go to the alias name, and are connected to server1, session
variables are saved - ON server1. Then you click a link, go to the alias -
and THIS time you go to server2. When it goes to process your request, it
can't - because it's not the server where your session data exists... So,
imho - it's just better to stay away from those and adopt a system that runs
on everything, and even runs when you get into a scenario when you need
highly-available servers...

hth

This is regarding the session management using Out of
proc session management(SQL SERVER). Among the samples
below which one is better to set the session?



1. There are 20 session variables and all of them
are being stored into session and accessed from session
and individual session object. Example: Session["a"]
= "XYZ", Session["b"]=100, Session["c"]="NAME", etc.
where values are of primitive data type or immediate
derivative of the primitive data types.

2. There are 20 session variable, a custom object is
created out of them. The custom object is stored into the
session. Example: NameValueCollection is an object where
data will be stored as NameValueCollection["a"] = "XYZ",
NameValueCollection["b"]=100, NameValueCollection["c"]
="NAME". Finally while storing it in the session the
NameValueCollection is used as Session["DATA"]=
NameValueCollection.

3)Is there any performance issue due to session
management through SQL SERVER provided by DOTNET framework




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top