Cookies

Introduction

Cookies, or browser cookies, are small pieces of data which the web server asks the client's web browser to store. Each request back to the server will include these pieces of data. The data is organized as key/value pairs.

Assign the value

To add a value to an existing key or create it if it does not exist and assign the value to it.

Cookie::set("name", "Hassan");

and You can change key name of variable.

Cookie::name("website", "url");

Check key

To check if a key exists, it returns true, and if it doesn't, it returns false.

Cookie::has("app", "name");

Get value

Get value of key.

Cookie::get("app", "name");

You can set a default value when the key is not present.

Cookie::get("app", "name", "Hassan");

and you can get all keys using all() method.

Cookie::all();

Delete keys

You can delete the key using delete() method.

Cookie::delete("name");

You can delete all the keys use destroy() method.

Cookie::destroy();

Last updated