Search code examples
perlmojolicious

In Mojolicious, how do I display my session's data?


I expect this to be marked as a dup, but I've searched and searched and can't find any questions that are similar, much less the answer. When a Mojolicious template has an error, you get a page that shows all of the session data.

Example of desired output

For debugging, I created a "dump" page that contains a deliberate error, but that seems to be a mite inefficient. Is there a simple way (like an already defined helper) to append the same well-formatted information to a page that I'm debugging?


Solution

  • You don't have to load Data::Dumper for that. One of the built-in helpers is Data::Dumper.

    % if ($debug_mode) { dumper $session; }
    

    or specific values:

    % if ($debug_mode) { dumper $session->some_value; }