Thursday, March 3, 2011

Cookie

learn java

Cookie
In JSP cookie are the object of the class javax.servlet.http.Cookie.
The Http protocol is a stateless protocol means that it can't keep a state
i.e. it can't persist values. To maintain a session we used the concept of cookies.
"A token is generated which contains user's information,
By this cookie, the server is able to identify the user."

Cookie is nothing but a name- value pair, which is stored on the client machine.
The cookies are saved to clients hard disk in the form of small text file.
Cookies helps the web servers to identify web users, by this way server tracks the user.
Cookies pay very important role in the session tracking.

Two types of cookies.
1) Non- secure session cookie:
This cookie can flow between the browser and server under the SSL or non- SSL connection.

2) Secure authentication cookie:
It is used to authenticate the data. This cookie flow over SSL.
This type of authenication cookie are used where the information security is very important. 


getComment()
Returns the comment describing the purpose of this cookie.

getMaxAge()

Returns the maximum specified age of the cookie.

getName()

Returns the name of the cookie.

getPath()
Returns the prefix of all URLs for which this cookie is targeted

getValue()

Returns the value of the cookie.

setMaxAge(int)
Sets the maximum age of the cookie.

setPath(String)
This cookie should be presented only with requests beginning with this URL.

setValue(String)
Sets the value of the cookie.

No comments:

Post a Comment

java-8-streams-map-examples

package com.mkyong.java8; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import java.util.List; im...