cookieJar
Created by David Pede on Jun 16, 2014.
What is cookieJar?
This extra includes a set of MODX Revolution snippets for setting, retrieving and deleting browser Cookies.
History
cookieJar was first written by David Pede (davidpede) and released on April 23, 2014.
Download
It can be downloaded from within the MODX Revolution manager via Package Management, or from the MODX Extras Repository, here: http://modx.com/extras/package/cookiejar
The source code and build script is also available on GitHub: https://github.com/tasianmedia/cookiejar
Bugs & Feature Requests
Bugs, issues and feature requests can be reported in the GitHub Repository, found here: https://github.com/tasianmedia/cookiejar/issues
Available Snippets
setCookie
The setCookie snippet can be called using the tag:
[[setCookie]]
getCookie
The getCookie snippet can be called using the tag:
[[getCookie]]
Available Properties
setCookie
Name | Description |
Default Value |
Added in Version |
---|---|---|---|
name | The name of the cookie. [REQUIRED] | 1.0.0-pl | |
value | The value of the cookie. This value is stored on the clients computer, do not store sensitive information. | 1.0.0-pl | |
expires | The time the cookie expires. This is a Unix timestamp so is in number of seconds. Use `0` to set a session cookie. Use any date in the past to delete a cookie. | 0 | 1.0.0-pl |
path | The path on the server in which the cookie will be available on. Use `/` to make available within the entire domain. | / | 1.0.0-pl |
domain | The domain that the cookie is available to. | 1.0.0-pl | |
secure | Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client. | 0 | 1.0.0-pl |
httponly | Indicates that the cookie will be made accessible only through the HTTP protocol. This means that the cookie wont be accessible by scripting languages, such as JavaScript. | 0 | 1.0.0-pl |
getCookie
Name | Description |
Default Value |
Added in Version |
---|---|---|---|
name | The name of the cookie to be returned. [REQUIRED] | 1.0.0-pl | |
tpl | Name of a chunk serving as a template. | 1.0.0-pl | |
toPlaceholder | If set, will assign the output to this placeholder instead of outputting it directly. | value | 1.0.0-pl |
Examples
setCookie
Set a Session Cookie:
[[setCookie? &name=`foo` &value=`foobar` &expires=`0` ]]
Set a secure Cookie that expires in one hour:
[[setCookie? &name=`foo` &value=`foobar` &expires=`3600` &secure=`1` ]]
Delete a Cookie named 'foo':
[[!setCookie? &name=`foo` &expires=`-3600` ]]
getCookie
Output the value of a Cookie named 'foo':
[[getCookie? &name=`foo` ]]
Output the value of a Cookie named 'foo', using a 'cookieTpl' chunk and assign the value to a placeholder:
[[getCookie? &name=`foo` &tpl=`cookieTpl` &toPlacholder=`cookieValue` ]]
Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab).