What is the purpose of %mdat (as compared to %udat) in Embperl?

158 Views Asked by At

I saw that session handling mentioned an %mdat as well as %udat hash. What is the difference and when and why would I use the %mdat hash?

1

There are 1 best solutions below

1
On

As noted in Embperl POD,

You can store any data in the %mdat hash and if any request comes to the same Embperl document, you will see the same values in that hash again.

Also, please note that the "you will see" wording in POD above is somewhat misleading, which may have contributed to your confusion.

The main Embperl documentation provides a more precise answer that removes the confusion:

The next time any user hits the same Embperl page, Embperl fill the %mdat hash from Apache::Session with the same values as you have stored within the last request to that page.

Please note the text I highlighted in bold - any user. Typical session data (as stored in %udat) is only stored and accessible for a specific user.

Therefore, %mdat acts as a sort of per-individual-embperl-page but user-independent data store.

To answer your "when" question, an example of using %mdat in practice would be per-page visit counter.