You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jure Simsic <ju...@literal.si> on 2000/06/13 12:29:13 UTC

Re: Apache::Session weirdness

I see. That explains it..
Perhaps it would be nice just to put a note about this in the
Apache::Session documentation..

Jure


Ken Miller wrote:
> 
> At 03:13 AM 6/10/00 +0200, Jure Simsic wrote:
> >I'm tryng to use Apache::Session and store a bunch of data into a
> >(complex) hash (using FileStore). The weirdest thing, that made me
> >banging my head for a while was, that when i first initialised the
> >session, everything was stored fine. But after restoring it and trying
> >to update it, nothing got updated..
> >
> >At first it seemed thar it was some weird kind of perl/Apache::Session
> >thing, that it didn't get updated because i was working on a refference
> >on the hash
> >(~ $ref=\$session{key1}; $$ref{foo}="bar";..)
> >And I put it all back to lengthy writing ($session{key1}{foo}="bar"),
> >hoping that it will help but of course, it didn't. It did seem a bit odd
> >in the first place..
> >
> >Then i was going nowhere for a while, until i put at the end, just
> >before untie-ing the hash, $session{TIMESTAMP} = time(); and magically
> >everything got updated and back to normal!!???
> >
> >Hello? Is there something I'm missing?? Isn't that just plain weird or
> >is there something deeper?
> 
> The session hash reference is a tied var.  When you follow a reference past
> the first level, the tied methods don't get invoked.  When you update the
> top level (as you did with the time()) you cause the tied methods to be
> invoked, and subsequently, the data is stored.
> 
> The last thing I do in my handlers, right before I untie the hash, is to
> update a timestamp, just as you did.
> 
> Hope that explains it.
> 
> Cheers!
> 
>         -klm.
> 
> +----------------------------------+---------------------------------------+
> | Kenneth L. Miller, Consultant    | "And as you rise above the fearlines  |
> | Shetland Software Services Inc.  |  in the frown you look down, hear     |
> | klm@shetlandsoftware.com         |  the sound of the faces in the crowd" |
> |                                  |        - Fearless, Pink Floyd         |
> +----------------------------------+---------------------------------------+

-- 
Jure Simsic
email: 	jure.simsic@literal.si
	jure.simsic@uni-lj.si

Re: Apache::Session weirdness

Posted by Perrin Harkins <pe...@primenet.com>.
On Tue, 13 Jun 2000, Jure Simsic wrote:

> I see. That explains it..
> Perhaps it would be nice just to put a note about this in the
> Apache::Session documentation..

It's already there:

      "Note that Apache::Session does only a shallow check to see
       if anything has changed.  If nothing changes in the top
       level tied hash, the data will not be updated in the
       backing store.  You are encouraged to timestamp the
       session hash so that it is sure to be updated."

- Perrin