Session & Cookies
What is Session?

In Session we save value in session variable and this variable is available to all pages of the application. For this purpose first load session library then save session data in variable, then we can fetch this data in all pages.

Load Session Library


How to create session?

$this->session->set_userdata('username', 'shishirphpdeveloper');

where username is session name and shishirphpdeveloper is data for this session.

How to access session?

echo $name = $this->session->userdata('username');

Here we access session(username).

How to delete session?


Here we delete session(username).

What is cookie?

Cookie is similar to session, cookie is also save data and available in all page of the application but difference is that
Cookie create txt file and store on client computer with specified time.

Load Cookie Library


How to create cookie?


where username is a cookie name,  shishirphpdeveloper is data and 10 sec is time for this cookie avaiable.

How to access cookie?

echo  $name = get_cookie('username');

Here we access cookie(username).

How to delete cookie?


Here we delete cookie(username).