Home » , » Difference between Cookie and Session in PHP

Difference between Cookie and Session in PHP

Written By Unknown on August 18, 2014 | Monday, August 18, 2014

Relation or Difference between session and cookies in php Cookies and sessions both are used to store values or data,But there are some differences a cookie stores the data in your browser memory and a session is stored on the server.

Cookie data is available in your browser up to expiration date and session data available for the browser run, after closing the browser we will lose the session information.

Cookies can only store string data,but session stored any type of data.we could be save cookie for future reference, but session couldn’t. When users close their browser, they also lost the session.
Cookies are unsecured,but sessions are highly Secured.

You lose all the session data once you close your browser, as every time you re-open your browser, a new session starts for any website.

Cookies stores some information like the username, last visited Web pages etc. So that when the customer visits the same site again, he may have the same environment set for him. You can store almost anything in a browser cookie.when you check the ‘Remember Password’ link on any website, a cookie is set in your browser memory, which exists there in the browser until manually deleted. So, when you visit the same website again, you don’t have to re-login.

The trouble is that a user can block cookies or delete them at any time. If, for example, your website’s shopping cart utilized cookies, and a person had their browser set to block them, then they could not shop at your website.

0 comments:

Post a Comment