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 Answers
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 fromApache::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.
-
1BTW, I must admit that in several years of Embperl based web development I *never* had any reason to use `%mdat` – DVK Jan 10 '11 at 21:34