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     |
| [EMAIL PROTECTED]         |  the sound of the faces in the crowd" |
|                                  |        - Fearless, Pink Floyd         |
+----------------------------------+---------------------------------------+

Reply via email to