473,399 Members | 4,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Session object

I have an asp.net application that uses classes to store data between the
user interface and the SQL Server database. Each user needs to see only their
data at any time, therefore I am using session to hold the classes. Currently
I use this on page load:
XProject = Session("XProject")
where XProject is the class I require to be at session level.
My question is, for this to be correct, and to stop data leaking to other
users if they are executing code at the same time, do i need to put a:
Session("XProject") = XProject
before redirecting to other pages in the site?
I'm still quite new to session and my site appears to read and write data
correctly, but from time to time, when a few users are using the web
application, data can be saved on one users' project and be seen on others,
causing errors and security risk.
Any help would be great, thanks in advance
jsale

Nov 19 '05 #1
4 1185
JSale,
With the little bit you've given us, I'd have to assume something might be
wrong with your XProject. Sessions are per-user...nothing special needs
to happen for this to be true. Therefore, I'd say the problem is that *you*
are putting other people's data into other people's session - maybe via some
complex referencing.

Not too sure what you are getting with Session("XProject") = XProject...at
some point you obviously have ot create the session object. But when you
subsequently get the object, it's a reference and you therefore don't need
to keep updating Session.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"jsale" <js***@discussions.microsoft.com> wrote in message
news:4F**********************************@microsof t.com...
I have an asp.net application that uses classes to store data between the
user interface and the SQL Server database. Each user needs to see only their data at any time, therefore I am using session to hold the classes. Currently I use this on page load:
XProject = Session("XProject")
where XProject is the class I require to be at session level.
My question is, for this to be correct, and to stop data leaking to other
users if they are executing code at the same time, do i need to put a:
Session("XProject") = XProject
before redirecting to other pages in the site?
I'm still quite new to session and my site appears to read and write data
correctly, but from time to time, when a few users are using the web
application, data can be saved on one users' project and be seen on others, causing errors and security risk.
Any help would be great, thanks in advance
jsale

Nov 19 '05 #2
"jsale" <js***@discussions.microsoft.com> wrote in message
news:4F**********************************@microsof t.com...
I have an asp.net application that uses classes to store data between the
user interface and the SQL Server database. Each user needs to see only
their
data at any time, therefore I am using session to hold the classes.
Currently
I use this on page load:
XProject = Session("XProject")
where XProject is the class I require to be at session level.
My question is, for this to be correct, and to stop data leaking to other
users if they are executing code at the same time, do i need to put a:
Session("XProject") = XProject
before redirecting to other pages in the site?
I'm still quite new to session and my site appears to read and write data
correctly, but from time to time, when a few users are using the web
application, data can be saved on one users' project and be seen on
others,
causing errors and security risk.


If you never put the object anywhere other than in Session, then you should
not see it leak to other users. This should only be happening if the object
(or pieces of it) is stored in a Shared variable, a global variable in a
Module, or in Application state.

Look around your code for things like these (especially modules). I usually
recommend that all modules should be replaced with Classes, and this is one
of the reasons.

John Saunders
Nov 19 '05 #3
jsale wrote:
I have an asp.net application that uses classes to store data between
the user interface and the SQL Server database. Each user needs to
see only their data at any time, therefore I am using session to hold
the classes. Currently I use this on page load:
XProject = Session("XProject")
where XProject is the class I require to be at session level.
My question is, for this to be correct, and to stop data leaking to
other users if they are executing code at the same time, do i need to
put a: Session("XProject") = XProject
before redirecting to other pages in the site?
I'm still quite new to session and my site appears to read and write
data correctly, but from time to time, when a few users are using the
web application, data can be saved on one users' project and be seen
on others, causing errors and security risk.
Any help would be great, thanks in advance
jsale


What is stored in the Session is just a *reference* to your instanced class.
After you have updated the values in the referenced instance you don't
need to "put it back" in the session. That stored reference is still valid,
it now points to data that has been modified.

If data is "leaking" to other users, the problem should be somewhere else
(Application object? Cache? Database?)

Hans Kesting
Nov 19 '05 #4
Session is a memory space that is global to all pages of a given client
(user), but only to that client machine. As a memory space, it is only
necessary to put data into Session one time, unless the Session times out
(Sessions time out after 20 min. of inactivity).

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"jsale" <js***@discussions.microsoft.com> wrote in message
news:4F**********************************@microsof t.com...
I have an asp.net application that uses classes to store data between the
user interface and the SQL Server database. Each user needs to see only their data at any time, therefore I am using session to hold the classes. Currently I use this on page load:
XProject = Session("XProject")
where XProject is the class I require to be at session level.
My question is, for this to be correct, and to stop data leaking to other
users if they are executing code at the same time, do i need to put a:
Session("XProject") = XProject
before redirecting to other pages in the site?
I'm still quite new to session and my site appears to read and write data
correctly, but from time to time, when a few users are using the web
application, data can be saved on one users' project and be seen on others, causing errors and security risk.
Any help would be great, thanks in advance
jsale

Nov 19 '05 #5

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

Similar topics

5
by: Abhilash.k.m | last post by:
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...
13
by: | last post by:
Simple question, I think... I'm storing an object in the Session object. In the code behind I read that object: trx = CType(Session("Transaction"), BOCSTransaction) If I change any...
1
by: Santosh | last post by:
Dear All i am writting a code sending mail with attachement. i am writting code for sending mail in one page and code for attaching a file in the next page. aftet attaching a file i am taking...
8
by: YYZ | last post by:
I'm using asp, not asp.net. I've got some open ended questions that I was really hoping someone in here could answer, or direct me to some resources that will help me answer them on my own. ...
16
by: Jonathan Wood | last post by:
Greetings, I was wondering if anyone here has a good understaning of the Session object. I know there are options like the Session.Abandon method and the regenerateExpiredSessionId setting,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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
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,...

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.