What is the difference between cookies and session?

Answer Posted / yogita mahajan

Cookies are some values saved in browsers for a particular website o publicly accessible
The purpose of cookies is to help websites to identify visitors and retrieve their saved preferences
Cookies are also used to facilitate auto login by persisting user id in a cookie save in user’s browser
Because cookies have been saved at client side, they do not create performance issues but may create security issues as they can be hacked from browser

Session variables are usually the most commonly used.
When a user visits a site, it’s sessions starts and when the user become idle or leave the site, the session ends.
Session variables should be used to save and retrive user specefic information required on multiple pages.
Session variables consumes server memory, so if your may have a huge amount visiters, use session very carefully and instead of put large values in it try to put IDs and references

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is object type in c#?

549


Is array immutable in c#?

482


Contrast between an interface and abstract class?

543


What is the difference between final finally and finalize in c#?

448


Do events have return type c#?

510






What is ienumerator c#?

471


Which is faster iqueryable or ienumerable?

568


Explain about Destructor method?

549


What is iqueryable?

483


What is the difference between protected and private?

467


How string definitions will prevent escaping on backslashes in C#?

524


What Happens In Memory When You Box And Unbox A Value-type?

470


For methods inside the interface why can’t you specify the accessibility modifier?

551


Is hashset ordered c#?

501


What is difference between singleordefault and firstordefault?

483