PHP- Session Vs Cookies

Updated on September 1, 2017

What is session?

In simple words “session is the temporary storage for saving the user data’s ” on the web server. These Stored data’s will be deleted or destroyed automatically by the web server .

What are cookies?

Same as session but cookies stores the data’s on the web browsers.

Session Vs Cookies:

1.Cookies stores the data on the user’s web browser where as the session stores the data on the web server.

2.Cookies can store the data until it has been deleted by user explicitly, But the Session stored data’s automatically deleted once user left the site or the web browser closed.

3.In case of the login enabled web pages user needs to login every time they visit for session enabled web pages. Where as re-login is not required on every visit as cookies stores the data’s on the user’s web browsers permanently.

4.User can disable web pages not to use the cookies, In this case those web pages become useless. But session cant be blocked by user, So in any case session will work without any problem.

5.The session data’s can ready easily while transfer over http protocol until security mechanism used. Where as the cookies data cant be read.

Was this article helpful?

Related Articles

Leave a Comment