(Quick Reference)

session

Purpose

The {grailsdocs}ref/Servlet%20API/session.html[session] object is an instance of the Servlet API’s {javaee}javax/servlet/http/HttpSession.html[HttpSession] class

Examples

class UserController {

    def logout() {
        log.info "User agent: " + request.getHeader("User-Agent")
        session.invalidate()
        redirect(action: "login")
    }

    def login() {}
}

Description

The {javaee}javax/servlet/http/HttpSession.html[HttpSession] class is useful for associated session data with a client.

Note The additional methods added to the {grailsdocs}ref/Servlet%20API/session.html[session] object are documented in the Grails Servlet API reference guide