Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

While web development Which is better cookies or session?

user-image
Question added by Mehbuba Abera , Full Stack Software Engineer , Hagbes Private Limited Company
Date Posted: 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
by 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
by 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
by 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
by 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
by 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

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.