What is the difference between PHP session and cookie?

The main difference between sessions and cookies, ie, cookies are stored in the user’s browser, and sessions are not.

Cookie
A “cookie” is a file that is physically stored on browser(your computer) and retained when you leave a web site and go somewhere else.

If a user has a login name and password, this can be set as a cookie in their browser so they do not have to re-login to your website every time they visit.

Session

A session is a series of related HTTP requests and responses that together constitute a single conversation between a client and server.

Session variables hold information about one single user, and are available to all pages in one application.It will retain until user do not close the browser window.

Sessions work by creating a unique identification(SID) number for each visitor and storing variables based on this ID. It helps to prevent two users’ data from getting confused with one another when visiting the same web page.