hi, How to use cookie in volt??
I use {{ cookie.username }} in volt template, but nothing output.
Thanks.
i'm not sure how to use cookie in volt but you can use it with DI
Register cookie in DI can only use in PHP codeļ¼ can't use in volt template.
In volt you have to do:
{{ cookies.get('username').getValue() }} // UPDATE: this also works {{ cookies.get('username') }}
Check the example in the docs.
By default, Volt engine has access to IoC (i.e. services.php), which means that one can access any service object by it's name. So if you have a cookie service defined (or not defined, if you use Factory Default) you have access to it.
services.php
cookie