473,509 Members | 6,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session variables

Hi,

Is there any know problem using session variables ?
My website won't have more than 20 simultaneous connections, and i would
like to use 5 session variables containing strings...
I know than with ASP, it was not really recommended, what about ASP.NET ?

Thanks !
Nov 19 '05 #1
7 1834
There's nothing wrong with using them, but there are better alternatives.
"Gerald" <an******@nospam.com> wrote in message
news:es**************@TK2MSFTNGP09.phx.gbl...
Hi,

Is there any know problem using session variables ?
My website won't have more than 20 simultaneous connections, and i would
like to use 5 session variables containing strings...
I know than with ASP, it was not really recommended, what about ASP.NET ?

Thanks !

Nov 19 '05 #2
Nothing wrong with them in ASP and there is nothing wrong with them in
ASP.NET.
Particularly value types like strings and ints.

--
2005 Microsoft MVP C#
Robbe Morris
http://www.robbemorris.com
http://www.masterado.net/home/listings.aspx

"Gerald" <an******@nospam.com> wrote in message
news:es**************@TK2MSFTNGP09.phx.gbl...
Hi,

Is there any know problem using session variables ?
My website won't have more than 20 simultaneous connections, and i would
like to use 5 session variables containing strings...
I know than with ASP, it was not really recommended, what about ASP.NET ?

Thanks !

Nov 19 '05 #3
Thanks, wich alternatives are better ?
Nov 19 '05 #4
"Gerald" wrote:
Hi,

Is there any know problem using session variables ?
My website won't have more than 20 simultaneous connections, and i would
like to use 5 session variables containing strings...
I know than with ASP, it was not really recommended, what about ASP.NET ?

Thanks !


Hi, i wouldnt call them problems, theres just stuff to be aware of. Like if
your site is spread across a web farm, youll need to use an out-of-process
session state instead of in-process. Also if that server gets rebooted then
ppl will lose their session state. But if theres only going to be 20 users
and 1 web server then there shouldnt otherwise be any real negatives to using
session state, as long as that server isnt running w/ 128MB of RAM!

HTH
Nov 19 '05 #5
Writing to a database, rather than saving per-user values in memory and
potentially needing to save huge amounts of data in RAM.

Using cookies for non-critical application data.
"Gerald" <an******@nospam.com> wrote in message
news:ud**************@TK2MSFTNGP15.phx.gbl...
Thanks, wich alternatives are better ?

Nov 19 '05 #6
Hello Scott M.,

At which point you're just offloading the bottleneck, right? Writing to/reading
from a database is one of the most expensive operations you can perform.

The true answer here is that Session variables used judiciously are ok. Issues
will come up if you do things such as storing every little detail in Session
or need to have session access across a web farm.

--
Matt Berther
http://www.mattberther.com
Writing to a database, rather than saving per-user values in memory
and potentially needing to save huge amounts of data in RAM.

Using cookies for non-critical application data.

"Gerald" <an******@nospam.com> wrote in message
news:ud**************@TK2MSFTNGP15.phx.gbl...
Thanks, wich alternatives are better ?


Nov 19 '05 #7
Reading/Writing to a DB is not the CPU and bandwidth hog that it once was.
This solution is widely considered to be the most stable and robust way to
persist state.

Now, should it be used to store short-term data or for every piece of data
needing to be persisted? No, and I never said it should be. I only said
that there are better alternatives to sessions (which, by the way, may not
even be an option since many web server admins turn off the server's ability
to use sessions because of the tendency to over use them or use them
incorrectly).

The *true* answer is that there is no one solution. The best sites use a
bit of several techniques where it makes sense to do so. I love using
cookies because it "off-loads" the storage to the client. But, as you know,
cookies can be turned off at the client level (as well as them being
susceptible to corruption). So, I only use them for non-critical data
storage like storing a user's preferences.

Sessions are easy enough to use, but can cause serious memory issues on the
server (even if they are used sparingly in code). Additionally, when a
client turns off cookies, they may also be turning of "per session cookies"
which means that server sessions are effectively turned off as well. Not to
mention the issues that come up with the use of sessions in web farm
environments.

Hidden form fields and querystrings are other ways to move data around but
they are also susceptible to corruption and querystrings in particular have
limits on the amount of data that can be passed.

So now we come to database storage....This can not be turned off by the
client, so it is reliable. There are no practical limits on the amount of
data that can be stored. Web Farm situations don't impact their use. The
possibilities of data loss due to a server crashing are eliminated, etc.,
etc., etc. Because we live in a world with faster servers and higher
bandwidth that ever before, using a database for persisting data is not the
taboo that it once was. Today, it is widely considered to be the "only"
choice by many serious web developers.

"Matt Berther" <mb******@hotmail.com> wrote in message
news:22***************************@news.microsoft. com...
Hello Scott M.,

At which point you're just offloading the bottleneck, right? Writing
to/reading from a database is one of the most expensive operations you can
perform.

The true answer here is that Session variables used judiciously are ok.
Issues will come up if you do things such as storing every little detail
in Session or need to have session access across a web farm.

--
Matt Berther
http://www.mattberther.com
Writing to a database, rather than saving per-user values in memory
and potentially needing to save huge amounts of data in RAM.

Using cookies for non-critical application data.

"Gerald" <an******@nospam.com> wrote in message
news:ud**************@TK2MSFTNGP15.phx.gbl...
Thanks, wich alternatives are better ?


Nov 19 '05 #8

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

Similar topics

6
2366
by: Al Jones | last post by:
This is a repost form the vbscript newgroup - if this isn't the appropriate group would you point me toward one that is. Basically, I seem to be losing session data part way though preparing an...
4
5574
by: PJ | last post by:
A particular page seems to be having issues with correctly setting Session variables. I am setting a couple of session variables on the Page_Unload event. While stepping through code, the...
10
3478
by: tshad | last post by:
I have been using the default session state (InProc) and have found that I have been loosing my information after a period of time (normally 20 minutes). Is there anyway to find out how much...
18
3401
by: BillE | last post by:
When a user opens a new IE browser window using File-New-Window the integrity of an application which relies on session state is COMPLETELY undermined. Anyone who overlooks the fact that...
3
2227
by: veenna | last post by:
Hi all, I have a page in asp.net. A button click in the page will open a pop-up. I have used btn.attributes.add("onclick", ""); to open the pop-up. Now if session is expired, it is opening the...
0
7347
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7073
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3218
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1571
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.