ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

While web development Which is better cookies or session?

user-image
تم إضافة السؤال من قبل Mehbuba Abera , Full Stack Software Engineer , Hagbes Private Limited Company
تاريخ النشر: 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
من قبل 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.

Arun Singh
من قبل Arun Singh

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
من قبل 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
من قبل Saul Mukasa , IT Technical Support Specialist , CodeIT Systems Uganda

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

Gurrala Rakesh
من قبل Gurrala Rakesh

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

Mohammed Ansar Mohammed Shafras
من قبل 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
من قبل 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.

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟