Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

While web development Which is better cookies or session?

user-image
Question ajoutée par Mehbuba Abera , Full Stack Software Engineer , Hagbes Private Limited Company
Date de publication: 2023/08/15

Session is preferred when you need to store short-term information/values, such as variables for calculating, measuring, querying 

Cookies is preferred when you need to store long-term information/values, such as user's account

Aleesha  Noushad
par Aleesha Noushad , Full Stack Developer PHP , Hitek Services LLC

It Depends on the your requirement , cookies will be save in browser and session in backend. you can select according to your requirement.

I would prefer you to choose cookies because you can save or delete them according to your need and in session, it automatically vacate when the browser is closed

Ali Shah
par Ali Shah , Software Quality Assurance Analyst , Contour Software

Here are some considerations when choosing between cookies and sessions:

  • The amount of data you need to store: If you need to store a lot of data, sessions are a better choice. Cookies have a limited size, so they are not suitable for storing large amounts of data.
  • The frequency of user interaction: If users interact with your website frequently, sessions are a better choice. Cookies can be deleted by the user or by the browser, so they are not reliable for storing data that needs to be accessed frequently.
  • The security of the data: If you need to store sensitive data, sessions are a better choice. Cookies are less secure because they are stored on the user's computer.

I hope this helps!

Saul Mukasa
par Saul Mukasa , IT Technical Support Specialist , CodeIT Systems Uganda

I'd say both since they work together. However sessions are preferred definitely.

Sessions are more secure than cookies because the data is stored on the server-side.

Mohammed Ansar Mohammed Shafras
par Mohammed Ansar Mohammed Shafras , Senior Software Engineer , Repe Digital Pvt. Ltd. – Indigo Teams

Session are better, unless cookies are also well encrypted like JWT etc.

Muhammad Nouman
par Muhammad Nouman , IT Manager Project Manager , ALMUSA SOHAIB FOR MEDICAL & LABORATORY

Session are more secured compare than cookies. Cookies stored data in text file. Session save data in encrypted form. Cookies stored on a limited data.

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?