Question #96899

What is the difference between cookies and session? In what circumstance should someone use
cookies or session? Support your answer with practical Examples.

Expert's answer

Cookies are data that the server can leave at the client (browser). Clearly: 

A client arrives, asks the server for a page.


The server in the response headers can set cookies. For example, issuing two headers: Set-Cookie: foo = 123 and Set-Cookie: bar = baz - i.e. - "remember, foo - 123, and bar - baz".


At the next call the client, if he decided to remember, tells the server "Cookie: bar = baz; foo = 123. "



A session is something that allows you to distinguish one user from another, and usually stores this data somewhere. For example, remember an authorized user.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS