Link to home
Start Free TrialLog in
Avatar of rruth
rruth

asked on

Session state management

Experts,

This is a question of session state management. I’m developing a presentation application where there are three levels of state within the application/module. This application is a module that is independent of all other like modules that could be running at the same time.

The principle of the application is that there is a moderator/admin that can control the timing on multiple slide/text pages. Numerous participants can log in to participate in the each presentation. Each participant can see all other participant’s names that are logged in to the same presentation but can only control their own state (login/logout, and other controls).

The top level of state is the presentation level and encompasses all other levels of that presentation.

The second level is the presentation administrator who can control each slide of the presentation that all participants can see.

The third is the participant level of a presentation where multiple participants can log into a presentation and can see the names of all the other participants that are logged in but can only control their own login/logout and individual controls.

My problem is that when multiple presentations are being given simultaneously, all participants from simultaneously running presentations show up in all the presentations and not just the presentations that they signed in to.  What scope variables can I use to:

1.      Keep each presentation module’s variables unique from all other simultaneously running presentations.
2.      Keep each participant’s variables unique from each other in the same presentation.

I’m not looking for actual code but coding strategies. I really appreciate any help you can give!!!
ASKER CERTIFIED SOLUTION
Avatar of wytcom
wytcom

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JeffHowden
JeffHowden

It would be quite helpful to know what you're using currently to manage all of this.  Likely there's a solution that involves only minor tweaks to get the functionality you're looking for.
Avatar of rruth

ASKER

Yes I've set the application up very similar to your suggestions. My problem again is state management. I need to track each individual participant and the moderator individually in their own browser window. For instance: when a participant logs in, I set a session variable called “participantType” with either the values of “participant” or “moderator” depending on who logs in and then insert him into a database. I use the database to continually show who has logged in. The problem is that each successive login overwrites the original value of the session variable loosing my session state for that browser. As each browser window is opened for login, I need to track who owns that window so a participant or a moderator can control their own state. In other words, if a participant wants to log out and clicks the “logoff” button it logs him off and not one of the other participants. Each browser needs to know who is controlling it.

I have been able to successfully keep state at the browser level by passing a unique url id variable. When a person logs in I set the url variable and as long as it isn’t dropped, I can use the id to control logging in and out of the database and other individual functions. By doing this each participant can control their own unique little world with out affecting anyone else in the presentation. Url variables are too easily dropped or played with. I need a more secure way of keeping track of each browser.

I know this is probably really easy, but any help would be very appreciated!
Instead of using a url variable, use a cookie.
>The problem is that each successive login overwrites the original value of the session variable loosing my session state for that browser.

It sounds like you need to separate the session variables from the database.  Use session variables only to control the individual users session.  Use the database as a reference to provide information on the state of the presentation as a whole (other users that are logged in etc.)

Incidentally, I use a state based and event driven approach to all my coldfusion projects.  I learned the concepts from the book Constructing the User Interface Using Statecharts by Ian Horrocks (doesn't cover coldfusion at all, but the concepts are adaptable to any language)
 
Avatar of rruth

ASKER

I guess I'm having troubles explaining what's happening. The easiest way to explain it is that my session variables are not maintaining the session. When I open up the login page and log in,  that sets my session variables. I then open up the same page in another browser window and log in with different parameters. The second login over rights the session variables from the login on the first window. In other words if I do a refresh on the first login window all the session variables show the values from the login of the second window. I need a unique session started everytime someone logs in. This has nothing to do with the database. The database is just where I store global data, not session data. Each browser when it is opened and there is a login, needs to start a new session that can't be over written by the next login. Once logged in, each page is set to do a refresh every 25 seconds so that all data can be updated in all browsers as participants log in and are inserted into the database.

I'm really sorry if I haven't been real clear. I do appreciate your patience and help!!!!
Then it's important to know how you're maintaining the session.  Are you using cookies?
Are we using the same terminology?  For "session variables" I think of CF session variables that apply when you have session management turned on for your application.  Then you access these as session.thisVariable and session.thatVariable.  Ideally, these session variables should be strictly associated with a single session of a single user.  You should expect each new user and each new session to get a fresh set of session variables that are completely independent of other users and sessions.
Avatar of rruth

ASKER

I figured out what the issue is. When a browser window is opened on a local machine, CF starts a session. Any other windows that are opened after, are included in that session. The application that I'm developing requires that I have two windows open on one machine, each with unique values for the same variables in each window. That is why the session variables were not working. I don't think that CF allows two session running at the same time on the same machine, please tell me if I'm wrong.

How I worked it out was with cookies. When a cookie is set, it stays unique with each browser window that's opened. I just have to verify that cookies are enabled for each page and throw an error message if they are not. I don't like to use cookies but I know of no other way to do this.

ruth
Using url variables would get you what you want as well.  Cookies are actually causing part of the problem because they're shared by browser windows.