A cookie is a small file that server embeds in the user's system which is used to identify a user.

In Yii, each cookie is an object of yii\web\Cookie.

The yii\web\Request (Collection of submitted cookies in a request) and yii\web\Response (Collection of cookies that need to be sent to a user) maintains the collection of cookies via the property named cookies.

Controller deals with the cookies request and response in an application. Hence, cookies should be read and sent in controller.

# Setting Cookies

Send cookies to the end users using the following codes.