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 the syntax for calling an overloaded constructor within a constructor (this() and constructorname() does not compile)?

523


What is a destructor in c#?

526


What are the desktop applications?

469


What is a console device?

484


How do you escape a character?

491






How do you inherit a class into other class in c#?

483


Is c sharp and c# are same?

514


What is a predicate in c#?

485


Explain the difference between the system.array.copyto() and system.array.clone()?

497


What is a dictionary in c#?

498


How does foreach loop work in c#?

485


What is exe in c#?

498


What is type safe code?

476


What is method in c#?

477


What is an ienumerable in c#?

545