How to use grails tag session scope?


I am trying to use the g:set tag on my gsp. As long as I am in one page and the scope is default or page, it works fine. When I am trying to change the scope to session its not working.

My understanding is I should be able to access that variable not only on that page but also on others when the scope is session, however, I might be wrong.

In a brand new 2.0.3 application I have this script on my index.gsp body and it works as expected.

<g:set var="bar" value="${new Date() - 7}" scope="page" /> <div class="message" role="status">${bar}</div>

However if I change the scope to session it doesn't work,

<g:set var="bar" value="${new Date() - 7}" scope="session" /> <div class="message" role="status">${bar}</div>

neither on any other page.


Have you tried:

<div class="message" role="status">${session.bar}</div>

<a href="http://grails.org/doc/latest/guide/theWebLayer.html#variablesAndScopes" rel="nofollow">http://grails.org/doc/latest/guide/theWebLayer.html#variablesAndScopes</a>


  • D3 - Drawing a path between DOM elements
  • Show message when Tform2 is created?
  • Bootstrap navbar stays expanded on route change
  • Mod rewrite redirection to another domain if file not exist
  • Excel distinct count with conditions
  • How do I remove all but some records based on a threshold?
  • C# fibonacci function returning errors
  • How to get current document uri in XSLT?
  • Convert Type Decimal to Hex (string) in .NET 3.5
  • What is the purpose of TaskExecutor in spring?
  • Admob requires api-13 or later can I not deploy on old API-8 phones?
  • Meteor: Do Something On Email Verification Confirmation
  • DomPDF {PAGE_NUM} not on first page
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • Javascript simulate pressing enter in input box
  • C# - Serializing and deserializing static member
  • Sending data from AppleScript to FileMaker records
  • Where to put my custom functions in Wordpress?
  • Importing jscolor library in angular 2
  • Weird JavaScript statement, what does it mean?
  • How do you troubleshoot character encoding problems?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Apache 2.4 - remove | delete | uninstall
  • RestKit - RKRequestDelegate does not exist
  • How to format a variable of double type
  • Matrix multiplication with MKL
  • A cron job substitute?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • How to include full .NET prerequisite for Wix Burn installer
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • WPF Applying a trigger on binding failure
  • Proper way to use connect-multiparty with express.js?
  • Benchmarking RAM performance - UWP and C#
  • Hits per day in Google Big Query
  • File not found error Google Drive API
  • apache spark aggregate function using min value
  • Is it possible to post an object from jquery to bottle.py?
  • How to Embed XSL into XML
  • Converting MP3 duration time
  • Conditional In-Line CSS for IE and Others?