Escolar Documentos
Profissional Documentos
Cultura Documentos
ITITIU11008
What is Cookie ?
What is Session ?
What is the difference between Cookie and Session"
How to use Cookie ?
How to use Session ?
What is Cookie ?
Cookie is not a cookie you eat, it is a tiny text file that store the info of user in their PC such as
name, password, address, email, phone number
Each time the internet browser interacts with a website it will pass the cookie to the website
server. Only the cookies stored by the internet browser that relate to the domain in the
requested link will be sent to the server.
If user use the internet browser with Private Mode (Internet Explorer), Anonymous Mode
(Firefox), Incognito Mode (Google Chrome) is on then any input will not be stored, its
recommended when using a public computer.
What is Session ?
Same as cookie but the information will store on the website server. It has only a unique
identifier is stored on the client side (called a "session id"). This session id is passed to the
server every time the internet browser sends an HTTP request. The web app pairs this session
id with internal database and retrieves the stored information for user by the requested page.
// index.jsp
// index.jsp
<html>
<body>
<form action="Main.jsp" method="GET">
First Name: <input type="text"
name="first_name">
<br />
Last Name: <input type="text"
name="last_name" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
<html>
<body>
<form method=post
action="SaveName.jsp">
What's your name? <input type=text
name=username>
<input type=submit value=Submit>
</form>
</body>
</html>