PHP: Difference between Session and cookie

Session-

1. Session is a server side resource . (Stored in a server side )

Cookie-

1. Cookie is a client side resource . ( Stored in browser(client side )).


Session-

2. Session holds the multiple values.
3. It can store an unlimited amount of data.

Cookie-


2. Cookie does not hold multiple variable .
3. Cookies are stored limit amount of data . The allow size 4kb[4096bytes]

Session-

4. Session depends on the server, if a user closes the browser and again try to login. If the expiry time is remaining on the server then check and log in directly .if Session time is expired then redirects to login page .

5.Session related to the cookies. A session is a collection of data stored on the server and associated with a given user (via cookie containing an id code )

Cookie-


4. Cookie depends on the client side (browser) if a user closes the window and after return, he can direct login because of cookies stored information in the browser.If the cookies time is expired then return to the login again.

5. The cookie contains a bit of data stored by the browser. If the user generates a request to the browser then browser sent information to the server for every request. The browser sends information to the server to redirect login without putting any id and password.

Session-

PHP session example – Session in PHP

Session mini project .- Login with session using PHP and MYSQL database

Cookie-

PHP Cookies example – Cookies in PHP

Cookies Mini Project – Login system using PHP and MYSQL database

Recommended Posts:-