Showing posts with label What is difference between session and cookie in php. Show all posts
Showing posts with label What is difference between session and cookie in php. Show all posts

Wednesday 29 October 2014

Difference between cookies and sessions PHP


Difference between cookies and sessions PHP

The main difference between cookies and sessions is that cookies are stored in the user's browsers means client machine and sessions are not. This difference determines what each is best used for session value stores on sever.

A cookie can keep information in the user's browsers until deleted. If a person has a login and password, this can be set as a cookie in their browser so the do not have to re-login to your website every time they visit. you can store almost anything in a browser cookie.

The problem with sessions is that when you close your browser you also lose the session. so if you had a site requiring a login this could not be saved as a session like it could as a cookie.

The session will be deleted after the user has left the website.