title: How to use a shiro native session in a grails web application?
body: <p>Currently, I am using the default HttpSession object in both controllers and gsp pages:</p>
  
  <p>In controllers:</p>
  
  <pre><code>...
  session.mykey = anObject;  // adding an object to session
  ...
  if (session.otherkey) {    // performing some checking
  </code></pre>
  
  <p>In GSPs:</p>
  
  <pre><code>...
  &lt;g:if test="${session.mykey}"&gt;
  ...
  </code></pre>
  
  <p>I'd like to have a "remember me" functionality. Shiro has already it built in. However, as far as I understood, in order to do it I have to use the shiro native session mode (in Config.groovy: security.shiro.session.mode="native"). By default, it persists the session state, so objects will remain in the session as far as the cookie expires or the user logs off.</p>
  
  <p>Is my understanding right?</p>
  
  <p>Then i will have to change my controllers to this:</p>
  
  <pre><code>def shiroSession = SecurityUtils.subject.session
  shiroSession.setAttribute("mykey",anObject)
  ....
  if (shiroSession.getAttribute("otherkey") ){
  </code></pre>
  
  <p>And my views to this:</p>
  
  <pre><code>&lt;g:if test="${SecurityUtils.subject.session.getAttribute('mykey')}"&gt;
  </code></pre>
  
  <p>So, my questions are:</p>
  
  <ul>
  <li>Is that right? </li>
  <li>Can't I just use the previous way to access the session?</li>
  <li>Do I have to turn off the default http session in some configuration?</li>
  </ul>