When you visiting the most of all sites in internet, you see the messages about cookies. Cookies it’s a small piece of data, which sends with every request to server. Cookies allow to get more information about what user do on site during the session. In Hapi, you can simply start to work with cookies without any libraries.
Setting a global cookie
To set HTTP cookie we should you the .state method of server instance. The first argument – the cookie name, the second – options. Options object accepts the next popular properties:
httpOnly flag, the default value – true
time to live of session, the default value – null
secure flag, the default value – true
type of encoding, the default value – ‘none’, other values – ‘base64’, ‘base64json’, ‘form’, ‘iron’