| [reply] [d/l] |
You can use "global" in memory values, but only as constants. Once you change the value in one place, it only changes there. There's a couple of ways you can make read-write globals. Via a database (as mentioned above), via a second instance of Apache::Session (or CGI::Session) using a constant superLongSecretKeyThatDoesn'tFitTheAutoGenerateFormatKey (ahem) or something like IPC::ShareLite to get true "shared across all children" global variables.
The Database method might have some performance penalties, but the advantage is that if you every start load balancing web servers, your global variables are still global.
The Secret Session method, is probably the fastest and easiest to code, since you already have similar parts in your program, but it also has some security implications surrounding your secret session key.
The IPC::SharedLite method requires installing a new module and learning some new (but realively straight forward) techniques. The amount of "shared" memory on a system is much smaller than "main" memory (at least with Unix) so you can't cram it TOO full, but it will yield the desired effect. For what you're trying to do, I'd be tempted to pick this method.
| [reply] |
Probably that should be right. But then whats the way to override this problem??
And i just got a thought here, even after using CGI::Session, i will read the user id from the session stored and store it in a variable in that .cgi file. Anyways it becomes a global var. So how do i use it to maintain a persistent data.
thanks
| [reply] |
You need to manage the multi-user session info in a Storable. I couldn't find a CGI::Session::Driver::Storable, but it should be easy enough to write interface routines between CGI::Session::Driver and Storable. The latter has advisory locking routines which will be needed when updating the storable in the multi-session scenario.
| [reply] |