Hello Everyone, I am having a bit of an issue with how the 'name' attribute is being set on CGI::Session (CGI::Session->name). It is necessary to set the class value for 'name' before creating a session after which it is possible and useful to set it on the instance.
I have a base class that I use for multiple CGI::App sub classes, this setups the main support for CAP::Session. Since we have lots of different cgi based apps that do very different things and that shouldn't really share session data, I need a way to alter this name. The main problem is that some of these apps are mod-perl based, which is where the class value causes issues ( or has the potential for issues). I know that I could use the 'path' value but there are cases where two subclasses could use the same session but be at different paths... ( I know, I'm being a pain in the butt :) I have found a solution but I'm not sure its the best one. In the base class, I allow each class to set the name differently for each app as a parameter. The main problem I run into is to prevent issues with it storing that for all other sub classes, I need to do something like: ... in some code that is called as a init callback.... ## fetch current global name my $old = CGI::Session->name; ## change it temporarily until new session has been created CGI::Session->name( $self->session_name ); $self->session->name( $self->session_name ); ## restore global one CGI::Session->name( $old); This is pretty ugly but I couldn't figure out a way around it. This give me a brief amount of time where the package value is set and I hope that it doesn't get used (or reset) by another app. Most of the apps are used by just a few (or single) users so this isn't a huge problem. But it just doesn't feel right. >From looking at the CGI::Session code, I don't there is another way to do >this. Any ideas? One solution that I had was a new hash ref of parameters could be passed to 'new' and 'load' (of CGI::Session). Something like: CGI::Session->new( 'driver:File', $self->query, { Directory => File::Spec->tmpdir}, { name => 'SpecialName', update_atime => 1, .... } ); I am very willing to create a patch and tests for this new constructor option, if it makes sense to everyone. Also, I have noticed that CAP::Session uses CGI::Session->name is a few places where the instance may have changed the parameter and will require a patch to fix these issues. I am willing to produce a patch and test for these issues as well. Thanks, Lee ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################