Solution: Set and View a Cookie
Explore how to set and retrieve cookies in AdonisJs by implementing response.cookie and request.cookie methods. Understand defining routes and controller methods to handle cookies, enhancing your ability to manage client-server data within your full-stack applications.
We'll cover the following...
We'll cover the following...
Solution
The following is the complete implementation of the problem described here:
'use strict'
class TestController {
setcookie({ response }) {
response.cookie('product_id', 1201)
return 'Cookie set'
}
getcookie({ request }) {
return request.cookie('product_id')
}
}
module.exports = TestController...