class ExampleTagLib {
def oncePerSession = { Map attrs, body ->
def key = (attrs.key ?: 'default').toString()
def sessionKey = "taglib.oncePerSession.${key}"
if (!session.getAttribute(sessionKey)) {
session.setAttribute(sessionKey, true)
out << body()
}
}
}
session
Purpose
The session object is an instance of the Servlet API’s HttpSession class
Examples
<g:oncePerSession key="promo">
<div class="promo">Free shipping this week!</div>
</g:oncePerSession>
Description
The HttpSession class is useful for associated session data with a client.
| The additional methods added to the session object are documented in the Grails Servlet API reference guide |