Servlet Cookie Class

public class Cookie
Cookie is a small piece of textual information sent by the server to the client , stored on the client, are returened by the client for all requests to the server. A Cookie contains one or more name-value pairs with certain additonal attributes, which are exchanged in the response and request headers.

Method of Cookie Class
  1. public Object clone()
              This method overrides the standard Object.clone method to return a copy of this cookie.
  2. public String getComment()
              This method returns the comment describing the purpose of this cookie, or null if the cookie has no comment.  
  3. public String getDomain()
              This method returns the domain name set for this cookie.
  4. public int getMaxAge()
              This method returns the maximum age of the cookie, specified in seconds, By default, -1 indicating the cookie will persist until browser shutdown.  
  5. public String getName()
              This method returns the name of the cookie.  
  6. public String getPath()
              This method returns the path on the server to which the browser returns this cookie.  
  7. public boolean getSecure()
              This method returns true if the browser is sending cookies only over a secure protocol, or false if the browser can send cookies using any protocol.  
  8. public String getValue()
              This method returns the value of the cookie.  
  9. public int getVersion()
              This method returns the version of the protocol this cookie complies with.  
  10. public void setComment( String purpose)
              This method specifies a comment that describes a cookie's purpose.
  11. public void setDomain( String pattern)
              This method specifies the domain within which this cookie should be presented.  
  12. public void setMaxAge(int expiry)
              This method sets the maximum age of the cookie in seconds.  
  13. public void setPath( String uri)
              This method specifies a path for the cookie to which the client should return the cookie.  
  14. public void setSecure(boolean flag)
              This method indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.  
  15. public void setValue( String newValue)
              This method assigns a new value to a cookie after the cookie is created.  
  16. public void setVersion(int v)
              This method sets the version of the cookie protocol this cookie complies with.


Latest Tutorial

Most Visited Tutorial