[cgiapp] TT::Plugin::Dumper and CGI::Session

Barry Moore barry.moore at genetics.utah.edu
Mon Oct 29 14:50:31 EDT 2007


This is really a TT issue, and I'll post to that list also, but I  
thought I'd send it here as well since it has a good chance of biting  
other CAP users, so it would be good to have it in the archives.

Using CGI::Session at the same time as Template::Plugin::Dumper can  
cause problems.  The dumper plugin sets (among other things)  
$Data::Dumper::indent and $Data::Dumper::pad.  Since CGI::Session  
stores session data only when the session object goes out of scope,  
the Dumper plugin has already set these values as global variables.   
Then along comes CGI::Session and and uses the globally altered  
Data::Dumper to serialize your data (if you are using default  
serialization).  If you've used Dumper with something similar to the  
invocation suggested in the docs like below, your data is serialized  
with <br> tags included.

[% USE dumper(indent=0, pad="<br>") %]
[% dumper.dump(myvar, yourvar) %]

When you retrieve your session - boom!  You die with something like:

Error executing run mode 'session_retrieve': Failed to Create  
CGI::Session object :: Reason: new(): failed: load(): couldn't thaw()  
data using CGI::Session::Serialize::default ....

Anyway, it took me a while to figure out what was going on, so I  
thought I'd post it to the list so it's in the archives and under  
Google's all seeing eye.

Barry


More information about the cgiapp mailing list