common:setCookie / common:getCookie

These taglibs lets you set / get a cookie.

Parameters

Name Required Default Type Description
id (for getCookie) true (for getCookie)   Object/String The variable the cookie value will be stored in.
name false   Object/String The cookie name
value true   Object/String The cookie value
domain false     The cookie domain
path false   Object/String A domain path if needed
maxAge false   Object/String A maximum age before the cookie expires
         


ID-result variable contains: A String-object.

Examples

This below will result that the cookie "foo" will get the value "bar" but it expires when you close the browser.

<%@ taglib uri="infoglue-common" prefix="common" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<common:setCookie name="foo" value="bar" domain=".infoglue.com" path="/" maxAge="-1"/>

This below will result that the cookie "foo" will get the value "bar" which expires on the date you give it.

<%@ taglib uri="infoglue-common" prefix="common" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<common:setCookie name="foo" value="bar" domain=".infoglue.com" path="/" maxAge="${expireDateInMilliSeconds}"/>

This will result in a new context value being set with the value of the cookie "foo".

<%@ taglib uri="infoglue-common" prefix="common" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<common:getCookie id="fooCookieValue" name="foo"/>



comments powered by Disqus