472,985 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,985 software developers and data experts.

Shared Variable Vs. Session Variable

Hi all,

My question is more of a phylisophical one here, but I am wondering what
the difference is (effectively and performance wise) between using a
shared variable/static variable and using a session variable.

I have two different applications right now that effectively perform the
same action at one point. In the one application I created a shared
variable:

shared myTable as DataTable;

In the other application I used a session variable:

session("myTable") = myTable;

Both of these ways "seem" to perform identically... that is they both
produce the same end result when I use them.

What's your view on this?

John Kraft

Nov 17 '05 #1
4 11665
Shared variables are shared by every user using your web app. They last
until the web app shuts down.

Session variables are specific to a particular user. These last only for the
life of the session. If the session timeout is set to 5 minutes, after 5
minutes of inactivity the session is over, and the variable's value is gone
with it.

Session variables are going to be more costly as you are going to have a
copy of them per user.

The types of variables do not perform identially. If you have 2 people
accessing your application, they will share a copy of the Shared variable.
User1 can modify it - and User2 who accesses it afterwards sees the changes
User1 made.

With session variables, each user has their own copy of the variable, and do
not overwrite each other's changes.

"John Kraft" <jh*****@nospam.ilstu.edu> wrote in message
news:bn**********@malachite.ilstu.edu...
Hi all,

My question is more of a phylisophical one here, but I am wondering what
the difference is (effectively and performance wise) between using a
shared variable/static variable and using a session variable.

I have two different applications right now that effectively perform the
same action at one point. In the one application I created a shared
variable:

shared myTable as DataTable;

In the other application I used a session variable:

session("myTable") = myTable;

Both of these ways "seem" to perform identically... that is they both
produce the same end result when I use them.

What's your view on this?

John Kraft

Nov 17 '05 #2
Shared variables are shared by every user using your web app. They last
until the web app shuts down.

Session variables are specific to a particular user. These last only for the
life of the session. If the session timeout is set to 5 minutes, after 5
minutes of inactivity the session is over, and the variable's value is gone
with it.

Session variables are going to be more costly as you are going to have a
copy of them per user.

The types of variables do not perform identially. If you have 2 people
accessing your application, they will share a copy of the Shared variable.
User1 can modify it - and User2 who accesses it afterwards sees the changes
User1 made.

With session variables, each user has their own copy of the variable, and do
not overwrite each other's changes.

"John Kraft" <jh*****@nospam.ilstu.edu> wrote in message
news:bn**********@malachite.ilstu.edu...
Hi all,

My question is more of a phylisophical one here, but I am wondering what
the difference is (effectively and performance wise) between using a
shared variable/static variable and using a session variable.

I have two different applications right now that effectively perform the
same action at one point. In the one application I created a shared
variable:

shared myTable as DataTable;

In the other application I used a session variable:

session("myTable") = myTable;

Both of these ways "seem" to perform identically... that is they both
produce the same end result when I use them.

What's your view on this?

John Kraft

Nov 17 '05 #3
Have a couple of people hit the app at the same time as you and have them
choose different variables to set up myTable. Then, you will see the
difference between Shared/static and Session.

I worked on an app where another developer set up a static function to
retrieve info. It did not manifest through the pilot, as there was not
enough activity. Put into production, users began to see cities outside of
their control, as the city was cached in a static property. Ouch!!!

If the variable is application wide, static is fine. If it gets altered on a
per user basis, you will either have to cache in a static array, or use
session. The advantage of session is it drops out when the session dies.

NOTE: Behind the scenes, in .NET, static and session are fairly similar, as
session objects are cached statically.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"John Kraft" <jh*****@nospam.ilstu.edu> wrote in message
news:bn**********@malachite.ilstu.edu...
Hi all,

My question is more of a phylisophical one here, but I am wondering what
the difference is (effectively and performance wise) between using a
shared variable/static variable and using a session variable.

I have two different applications right now that effectively perform the
same action at one point. In the one application I created a shared
variable:

shared myTable as DataTable;

In the other application I used a session variable:

session("myTable") = myTable;

Both of these ways "seem" to perform identically... that is they both
produce the same end result when I use them.

What's your view on this?

John Kraft

Nov 17 '05 #4
Have a couple of people hit the app at the same time as you and have them
choose different variables to set up myTable. Then, you will see the
difference between Shared/static and Session.

I worked on an app where another developer set up a static function to
retrieve info. It did not manifest through the pilot, as there was not
enough activity. Put into production, users began to see cities outside of
their control, as the city was cached in a static property. Ouch!!!

If the variable is application wide, static is fine. If it gets altered on a
per user basis, you will either have to cache in a static array, or use
session. The advantage of session is it drops out when the session dies.

NOTE: Behind the scenes, in .NET, static and session are fairly similar, as
session objects are cached statically.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"John Kraft" <jh*****@nospam.ilstu.edu> wrote in message
news:bn**********@malachite.ilstu.edu...
Hi all,

My question is more of a phylisophical one here, but I am wondering what
the difference is (effectively and performance wise) between using a
shared variable/static variable and using a session variable.

I have two different applications right now that effectively perform the
same action at one point. In the one application I created a shared
variable:

shared myTable as DataTable;

In the other application I used a session variable:

session("myTable") = myTable;

Both of these ways "seem" to perform identically... that is they both
produce the same end result when I use them.

What's your view on this?

John Kraft

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: John Kraft | last post by:
Hi all, My question is more of a phylisophical one here, but I am wondering what the difference is (effectively and performance wise) between using a shared variable/static variable and using a...
3
by: ton | last post by:
Hi, I keep several variables in a statevalue like: Dim session As SessionState.HttpSessionState = System.Web.HttpContext.Current.Session session("connect") = " FKHFSF " I thought that these...
4
by: Sarah Marriott | last post by:
Our website contains session variables that are used to validate if a user is logged in etc. We have found that these variables are randomly lost while navigating the website. We set up some...
3
by: GHawley | last post by:
I have a fairly large application with about 200 users that uses Session variables. It would seem that occasionally these variables are being referenced incorrectly to the extent that different...
4
by: Don Miller | last post by:
I am using a Session variable to hold a class object between ASP.NET pages (in VB). In my constructor I check to see if the Session variable exists, and if it doesn't, I create one and populate it...
17
by: Control Freq | last post by:
Hi, Not sure if this is the right NG for this, but, is there a convention for the variable names of a Session variable? I am using .NET 2.0 in C#. I am new to all this .NET stuff, So, any...
2
by: Don Miller | last post by:
I use a Session variable to store a custom object (all properties contain strings) between postbacks. On occasion, mostly when I change and save code, when I refresh the web page to see the...
6
by: laredotornado | last post by:
Hi, When a user logs into our site, we create a session variable to denote the session is active and another to denote who is logged in. Once the user closes the browser and re-opens it, the...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.