On 5/10/05, Bart Simpson <[EMAIL PROTECTED]> wrote: > > --- Rick <[EMAIL PROTECTED]> wrote: > > I'm having problems with > > MasonX::Request::WithApacheSession (using > > Apache::Session::MySQL backend). The session is not > > being updated, so > > I can't save any data to it. I verified this by > > looking at the mysql > > logs. > > Are you timestamping your session each time you > updated it? it only updates if you change someting in > top level of session hash, thus usually you timestamp > the session in top level when updating it. > > $session->{hash}->{key} = $new_val ; # won't cause > update > > $session->{hash} = { key => $new_val }; # causes > update cause hash address changed in top level. > > See docs Apache::Session docs for details about this. > Other than this I've never had this problem. Don't use > mason though.
Interesting, it appears that the only API to the MasonX::Request::WithApacheSession is through the mason request object (global $m). In order to test what you have recommended, I created a session using purely the Apache::Session::MySQL class. I did this by creating a seperate "set.html" mason/html file which creates a new session and sets some session values. The code is below: -------------------BEGIN MASON CODE FOR "set.html"------------------------------------------------- <%perl> my %session; tie %session, 'Apache::Session::MySQL', undef, { Handle => $DBH, LockHandle => $DBH }; </%perl> <h3>Setting some of the session keys<h3> <%perl> $session{'car'} = { make => 'BMW', year => '2005', model => 'M3', color => 'Interlagos Blue' }; $session{'user'} = $USEROBJECT; </%perl> <h3>Dumping contents of %session <% $session{_session_id} %></h3> % for my $key (keys %session) { <h3><% $key %> = <% $session{$key} %></h3> % } <h3><a href="dump.html?id=<% $session{_session_id} %>">dump.html</a></h3> -------------------END MASON CODE FOR "set.html"------------------------------------------------- By viewing this page, the session key/values show up correctly in the HTML output. However, when I click the link to go to the dump.html page, nothing was saved. Below is the output for the dump.html page. -------------------BEGIN MASON CODE FOR "dump.html"------------------------------------------------- <%args> $id </%args> <%perl> my %session; tie %session, 'Apache::Session::MySQL', $id, { Handle => $DBH, LockHandle => $DBH }; </%perl> <h3>DUMPING Session from %session</h3> % for my $key (sort keys %session) { <h3><% $key %> = <% $session{$key} %></h3> % } <h3><a href="set.html">set.html</a></h3> -------------------END MASON CODE FOR "dump.html"------------------------------------------------- On this page, the only key/value pair is: _session_id => [MD5sessionidgoeshere] I checked the MySQL logs and there were only 3 calls to it: 2005 Query SELECT GET_LOCK('Apache-Session-f050450049018ff9d77c9e4697700b5f', 3600) 2005 Query INSERT INTO sessions (id, a_session) VALUES ('f050450049018ff9d77c9e4697700b5f','\0\0\0\n f050450049018ff9d77c9e4697700b5f\0\0\0 _session_id') 2005 Query SELECT RELEASE_LOCK('Apache-Session-f050450049018ff9d77c9e4697700b5f') No UPDATE statements even though I'm changing things in the top level hash. Any ideas? Rick