Tuesday, December 6, 2016

JavaScript Session vs Cookie - Q&A

Question:

What are the differences between SESSION and COOKIE?
Where each of them is located?
Is it possible for another site to see others cookie?

Answer

In terms of capabilities, cookies only allow you to store strings. sessionStorage allow you to store JavaScript primitives but not Objects or Arrays (it is possible to JSON serialise them to store them using the APIs). Session storage will generally allow you to store any primitives or objects supported by your Server Side language/framework.
Cookies location.
Sessionstorage & localstorage location.
A properly designed browser will not allow a website to access another website's cookies, as this would violate the cross-domain policy and be a major security issue.

No comments:

Post a Comment