473,320 Members | 2,162 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,320 software developers and data experts.

SessionHelper Class problem in ASP .NET

Hi,
I am facing the following problem while using my version of SessionHelper class in ASP.NET.

The scenario is as follows:

I have my version of SessionHelper Class where I store many of my session variables. One of them is UserID.

Now there is a MyCommon.vb module file where I have a global instance of this SessionHelper class. Again, in the module file I have few methods which I call from my main program.

Now the problem is that, if I declare a new instance of my session variable inside the methods of module file, then when I call say any method from my main program, then the value of my UserID returned from this local instance of SessionHelper classis, is the proper value of the required User.

But if I do not declare a local copy and try to get the value of UserID from the global instance of SessionHelper class which was declare in the module, then sometimes I get garbage values of UserID i.e. I get certain UserIDs with which I had previously logged in.

This question may not be very clear. If so, let me know, I will try to provide more details.

Thanks
Pawan.
Dec 12 '07 #1
3 2708
Frinavale
9,735 Expert Mod 8TB
Hi,
I am facing the following problem while using my version of SessionHelper class in ASP.NET.

The scenario is as follows:

I have my version of SessionHelper Class where I store many of my session variables. One of them is UserID.

Now there is a MyCommon.vb module file where I have a global instance of this SessionHelper class. Again, in the module file I have few methods which I call from my main program.

Now the problem is that, if I declare a new instance of my session variable inside the methods of module file, then when I call say any method from my main program, then the value of my UserID returned from this local instance of SessionHelper classis, is the proper value of the required User.

But if I do not declare a local copy and try to get the value of UserID from the global instance of SessionHelper class which was declare in the module, then sometimes I get garbage values of UserID i.e. I get certain UserIDs with which I had previously logged in.

This question may not be very clear. If so, let me know, I will try to provide more details.

Thanks
Pawan.
Hmm this is a problem with the way you are using your SessionHelper.

If you declare a static global instance of your SessionHelper class, every person that uses your website will be accessing the Same data.

Say one person visits your site, and after logging in their UserId is set to 1234.
Then another person visits your site a couple seconds later...since you're using a global variable, their UserID will be 1234 as well..unless you set it to something else.

Things can get pretty messed up if more than one person is using your SessionHelper instance at the same time.

You should create a SessionHelper per user to avoid this, especially if each person requires a unique UserID to identify them.

Does this make sense?
Dec 13 '07 #2
I would like to say that the global session variable is global only because its declared above all the methods in the Common.vb.....and not global at the application level.

Do you mean to say that if I make a session variable global(like this), even in the Common.vb file (which only contains some common methods), the session variable becomes global to the whole application.

Because in my case, I get proper value of session variable in almost every case. Its only that sometimes I get old session values.

Thanks
Dec 15 '07 #3
Frinavale
9,735 Expert Mod 8TB
I would like to say that the global session variable is global only because its declared above all the methods in the Common.vb.....and not global at the application level.

Do you mean to say that if I make a session variable global(like this), even in the Common.vb file (which only contains some common methods), the session variable becomes global to the whole application.
I don't know why, but I read your question incorrectly.
For some reason I thought you were using a static variable.

Now the problem is that, if I declare a new instance of my session variable inside the methods of module file, then when I call say any method from my main program, then the value of my UserID returned from this local instance of SessionHelper classis, is the proper value of the required User.


But if I do not declare a local copy and try to get the value of UserID from the global instance of SessionHelper class which was declare in the module, then sometimes I get garbage values of UserID i.e. I get certain UserIDs with which I had previously logged in.
Could you please post your code for this. I'm having a hard time understanding your question.
Dec 17 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Murat Tasan | last post by:
hi, i am having a small problem with constructing an inner class. i am using an inner class (and not a static nested class) because the methods of the inner class need access to the enclosing...
2
by: Fernando Rodriguez | last post by:
Hi, I need to traverse the methods defined in a class and its superclasses. This is the code I'm using: # An instance of class B should be able to check all the methods defined in B #and A,...
2
by: Gabriel Genellina | last post by:
Hi In the following code sample, I have: - a Worker class, which could have a lot of methods and attributes. In particular, it has a 'bar' attribute. This class can be modified as needed. - a...
3
by: Robert | last post by:
Python doesn't know the class of a method when container not direct class attribute: >>> class X: .... def f():pass .... g=f .... l= .... >>> X.g <unbound method X.f>
1
by: Oplec | last post by:
Hi, I'm learning C++ as a hobby using The C++ Programming Language : Special Edition by Bjarne Stroustrup. I'm working on chpater 13 exercises that deal with templates. Exercise 13.9 asks for me...
9
by: Banaticus Bart | last post by:
I wrote an abstract base class from which I've derived a few other classes. I'd like to create a base class array where each element is an instance of a derived object. I can create a base class...
5
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits...
3
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and...
0
by: emin.shopper | last post by:
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.