# cookie

## Purpose

Obtains the value of a named cookie

## Examples

Reading a cookie's value:

    Hello  <g:cookie name="myCookie" />

Or testing for existence:

    <g:if test="${cookie(name:'myCookie')}">Hello</g:if>

## Description

Attributes

- `name` - The name of the cookie

## Source

Show Source

    def cookie = { attrs ->
            def cke = request.cookies.find {it.name == attrs['name']}
            if(cke)
                out << cke.value
        }