PHP: Difference Between Session and cookie.

Technosmarter PHP

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 holding the multiple values.
3. It can store an unlimited amount of data.

Cookie-


2. Cookie is not holding multiple variable .
3. Cookies 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 log in. If the expiry time is remaining on the server then check and log in directly .if Session time is expired then redirect to log in again.

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 browser for every request. The browser sends information to the server to redirect login without putting any id and password.

Session-

PHP session example – Click Here

Session mini project .- Click Here

Cookie-

PHP Cookie example – Click Here

Cookies Mini Project – Click Here

Related