Difference between revisions of "Liquid Template Variables - cookies"
From Spiffy Stores Knowledge Base
m |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | The | + | The Liquid template variable '''cookies''' has the following attributes: |
== <code>cookies.''name''</code> == | == <code>cookies.''name''</code> == | ||
Line 13: | Line 13: | ||
You will need to use another method, such as JavaScript to create and update cookies. | You will need to use another method, such as JavaScript to create and update cookies. | ||
− | Most themes include the | + | Most themes include the Moo Tools Javascript framework, and this includes standard methods for creating cookies. |
The following code creates a ''theme'' cookie with the value ''blue''. This code can be included in the body of your page as required. | The following code creates a ''theme'' cookie with the value ''blue''. This code can be included in the body of your page as required. | ||
− | < | + | <pre><script type="text/javascript">Cookie.write('theme', 'blue', {duration: 14, path: '/'});</script></pre> |
+ | |||
+ | Documentation of the Moo Tools API is at http://docs.mootools.net/Utilities/Cookie | ||
+ | |||
+ | == Further Reference == | ||
+ | |||
+ | * [[Liquid Basics]] | ||
+ | * [[Liquid Tag Reference]] | ||
+ | * [[Liquid Filter Reference]] | ||
+ | * [[Liquid Variable Reference]] | ||
+ | * [[Liquid Paginate Tag|Pagination ]] |
Latest revision as of 13:16, 25 June 2018
The Liquid template variable cookies has the following attributes:
cookies.name
You can access any cookie by name.
For example, if you have created a cookie called theme, then its value can be accessed by
cookies.theme
Note that the Liquid variable, cookies, only provides read-only access to the cookies.
You will need to use another method, such as JavaScript to create and update cookies.
Most themes include the Moo Tools Javascript framework, and this includes standard methods for creating cookies.
The following code creates a theme cookie with the value blue. This code can be included in the body of your page as required.
<script type="text/javascript">Cookie.write('theme', 'blue', {duration: 14, path: '/'});</script>
Documentation of the Moo Tools API is at http://docs.mootools.net/Utilities/Cookie