ITP

IMCA - Web Development Using PHP

Difference between session and cookies ?

In : IMCA Subject : Web Development Using PHP

The main difference between sessions and cookies in PHP is where the data is stored

  • Cookies are stored on the user's browser , and they can see and sometimes change them. Cookies are used to keep track of small pieces of information like a username or a theme preference. They can be set to last for a certain time, even after the browser is closed.

  • Sessions , on the other hand, are stored on the server , not on the user's computer. Only a unique ID (called a session ID) is sent to the browser, usually through a cookie. This makes sessions more secure than cookies because users can’t directly access the data stored in them. 

In short:
Use cookies for non-sensitive data that you don’t mind being stored on the user’s computer.
Use sessions for sensitive or temporary data that should stay secure and only accessible on the server.

About us

A truly open platform where you may ask questions and get answers. We also provide comprehensive and easy-to-understand answers to question papers.  discover...

Site status

Flag Counter

Privacy Policy

Sitemap