Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Are Sessions OK?

Status
Not open for further replies.

crazyboybert

Programmer
Jun 27, 2001
798
GB
Hi All

I've been thinking a lot recently on using session variables in my .net applications but am having trouble getting by my reservations on using even though I have heard so much on how M$oft have improved them significantly withint the dotnet framework with problems such as variables not being avaiable across web farms being resolved.

I was wondering what peoples opinions were on the use of sessions in .net? Has anyone used them to great success in a commercial application or had any real problems with them either? Hopefully this won't open to big a can of worms *duck*....

Thanks for any input id be pleased to hear your thoughts.

Rob

------------------------------------

On with the dance! let joy be unconfined;
No sleep till morn, when Youth and Pleasure meet
To chase the glowing hours with flying feet.
-Byron

------------------------------------
 
Rob,
Unfortunately I think you have asked a questions that has as many answers as there are people on Tek-Tips. At my company we do use session variables for some things, but we try not to use them to much as they are still a memory hog. We have had not problems yet with session variables being lost, but we have not tried it with web farming yet. I hear it is actually quite easy to get this to work though. If you decide to go down the route of using sessions I think you and your development staff need to decide what is good to put on session and what is bad to put on it. We try to keep as little as possible on it. The problem is that if you need something from session and its not there then you have to figure out if this is "normal" so you can go back and reget the info, or if this is an error and you need to deal with it appropriately. I hope this helps with your decision some, and I'm sure someone will reply to me and tell me how I'm wrong on all accounts.

Ken
 
Although Session is greatly improved, I think the standard rules still apply: use session when you absolutely have to.

There are so many new ways to maintain data over pages and postbacks (ie. Viewstate, server.transfer, querystrings, etc.).

Sessions aren't bad, but to optimize performance you still want to make sure that the session will give you something that the other options won't.

hth

D'Arcy
 
So with some reservations I am using a Session variable to hold information onthe user which affects there maintain/edit/read rights within the application. It seems to make sense requesting this once on session start and not making an extra trip to the database everytime i need to authenticate. It seems ok performance wise so alls well I guess.

Strange behaviour though is when the application has just been rebuilt and is requested for the first time (and hence compiled). The very first page of the app request the users windows account and relates this to access rights in the database saving the result into a session. The odd thing is the first time the page loads these dont seem to be saved though the call to the database does occur and recives the results as expected. They just don't seem to make it to the session. Browse to another page and get denied access, refresh the homepage and bingo your in with access rights as expected.

Before anyone mentions Windows Authentication instead of this process its not an option as the access is related to the database the application is the front end too - not the application itself...

this only happens the first time after a rebuild. I just dont get it....


Rob

------------------------------------

On with the dance! let joy be unconfined;
No sleep till morn, when Youth and Pleasure meet
To chase the glowing hours with flying feet.
-Byron

------------------------------------
 
I use session all over the place.. mostly for serializing data that I'm going to have to use over and over again.. ie dynamic navigation, content, etc.

I also use the application state for similar reasons.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top