How do I set a cookie that expires after a certain time using Tritium?

224 views Asked by At

I'd like to create a cookie that expires within 5 minutes of the user visiting my page.

I know about add_cookie() function, but have no idea how to set it to expire.

1

There are 1 answers

1
hari ananth On

You can set cookies in the scripts/response_main.ts file as such:

set_cookie("cookie_name", "cookie_val")
cookie("cookie_name") {
  cookie.expires("Wed, 09 Jun 2021 10:18:14 GMT")
}

Check out this link for more info.