Sending Error Message to Template With No Logged In User - Craft 2 I'm working at getting error messages sent from my plugin to my template (on the front end), when there is no session (no logged in user). 
The plugin is for LDAP authentication.

Edit: For clarification, this plugin (and the error messages) will be for as-of-yet un-logged-in users.  Would a session structure be the only way to get the messages to those end users?

I've tried this (below), but I get the error message (below):

code in the plugin controller:   craft()-&gt;userSession-&gt;setFlash('msg_template',"Credentials were not accepted.")

code in the template:

{% set message = craft.app.session.getFlash('msg_template') %} 

{% if message|length &gt; 0 %}
{{message}} 
{% endif %}


error message:

Neither the property "session" nor one of the methods "session()", "getsession()"/"issession()" or "__call()" exist and have public access in class "Craft\AppVariable
You are mixing Craft 3 code with Craft 2. There is no native way to access the session in Craft 2 via Twig so you need to inject the functions with your plugin

See a working example here