in reply to Mason Sessions - problem Storing values

Apache::Session only saves the data when it gets destroyed. If you put it in a global, it never gets destroyed. The session modules for Mason on CPAN work around this by explicitly destroying %session. I'd suggest you use one of them instead of building your own.
  • Comment on Re: Mason Sessions - problem Storing values

Replies are listed 'Best First'.
Re^2: Mason Sessions - problem Storing values
by nacredata (Sexton) on Apr 20, 2005 at 00:56 UTC
    I am looking at the MasonX-Request-WithApacheSession module now, and will use it if I don't figure this out soon. I do like to understand things as best I can, though, which is worth some struggle. The items I add in that autohandler -- user permission level and group -- ARE saved, and the other info I want saved is visible at the end of that autohandler if I insert a print $session{SQLstatement} before the close of the autohandler. So that session value is not masked by the local *session; declaration in the init section, but they are also not saved as they are only around for that one request, while the above values persist. I do want to understand what is going on here with scoping, even if I use the module. thanks.
      I don't really understand your description of what you're doing, but you should go and read the Apache::Session docs. They make it pretty clear that you have to make sure the object gets destroyed. Your "print $session{SQLstatement}" will not affect anything one way or the other.
Re^2: Mason Sessions - problem Storing values
by nacredata (Sexton) on Apr 20, 2005 at 18:35 UTC
    So, anyway, I got it to work by making the tied %session lexically scoped in the autohandler and then passing a reference down to all other components. But I'm still curious how they got it to work with the global -- teh book specifically discusses a global, localized in the autohandler but available elsewhere as a global. If nothing else, that section of the book may need a little flushing out in the next edition. Thanks for the offers of help.