Sharing Session Variableshttp://forums.asp.net/t/342724.aspx/1?Sharing+Session+VariablesFri, 19 Sep 2003 15:12:19 -0400342724342724http://forums.asp.net/p/342724/342724.aspx/1?Sharing+Session+VariablesSharing Session Variables Hello all. I am having a real issue here. It is my understanding that session variables cannot be used on two PCs (workstations) as they are tied to the PCs browser via a Cookie. Also in the web.config file you use the following to state that you want to use the Session on your web server: By setting the mode="InProc" should allow IIS to control the sessions. Also making cookieless="false" it requires the browser to use a cookie to store the session ID. So with that said I will now state my problem. In the Global.asax, Session_Start method, I have some code that queries my database and stores some values in a couple of arraylists and then populates a Session variable for each arraylist. These arraylists, that are now stored in session variables, are used on pages later to create links. So if I log in as our Test account, which should have nothing stored in the arraylists because no data comes back for that account, I get redirected to my noaccess.aspx page as it should. Next I log as myself and I have several items that populate all of the arraylists. When I go to the first page where the arraylists are used I get all the correct information. Things are good so far. The problem comes in when I log back in as the Test user. Now instead of being redirected to my noaccess.aspx page as I was before I see the exact same thing I did while logged in as myself. Now just to show you how ODD this really is, I am logging in as the Test user on the DEV machine and logging in as myself on my LAPTOP. So I am actually on two different machines. I have looked at the SessionID for each machine when it loads the page and they are DIFFERENT. But the data is the same. Now while debugging from my laptop, logged in as the Test user on the DEV machine, I watch the arraylists and since no data is brought back from the database they are not populated. However, when I get to that page where the arraylists are used the data populates the links just like it did for me when I was logged in even though there is nothing in the arraylists. Now again I have to state that it only does this if I log in first as myself and then as the Test user. Otherwise the Test user account seems to work fine. All of this leads me to believe that these machines are sharing session variables. However, I also store the users name, retrieved from user.identity.name, in a session variable and it comes through fine in my "Welcome [insert name here]" as does the email address that is populated in the same way. I'm really stuck here because we are supposed to be testing this system but cannot start until I figure this out. System Information: DEV: P4 1.8 Ghz 512 MB Ram Windows 2003 Server Standard Edition Laptop: P4 2.0 Ghz 512 MB Ram Windows XP Professional Both systems are logged onto our corp. network and connected to it via a Linksys Hub. Hope someone can shed some light on this because I am stuck between a hard place and management. 2003-09-19T12:12:41-04:00342760http://forums.asp.net/p/342724/342760.aspx/1?Re+Sharing+Session+VariablesRe: Sharing Session Variables My suggestion would be to write your own session object that generates and stores session information in whatever database you're using. You then make yourself a class that inherits from System.Web.UI.Page and put your code in there to create the session object. All of your pages then inherit from your class. I have no idea if this ends up being less or more efficient than the built in session handling but it certainly works. You can then also run queries on your database against the session information. I believe there's some built in way within asp.net to do something like this but it's not secure for one thing (if I recall correctly that is) 2003-09-19T13:03:24-04:00342903http://forums.asp.net/p/342724/342903.aspx/1?Re+Sharing+Session+VariablesRe: Sharing Session Variables Unfortunatly that would take to much time to build and test and possibly slow the site down. What I am really trying to figure out here is WHY. My current thought for a work around is to use Cache with the SessionID as the unique identifier for each cache value. In this case it is only two arraylists (so far anyway) that seem to be affected. 2003-09-19T15:01:29-04:00