This is a discussion on Cookies within the Java Server Pages (JSP) forums, part of the Web Development category; Is it ok if you regularly delete cookies in JSP? If it is alright, how do you delete my cookies?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi..... cookie can be deleted using the following scriptlet: <% Cookie killMyCookie = new Cookie("mycookie", null); killMyCookie.setMaxAge(0); killMyCookie.setPath("/"); response.addCookie(killMyCookie); %> |
| |||
| There are two kinds of cookies in jsp: persistent cookies and temporary cookies. A persistent cookie is one stored as a file on your computer, and it remains there when you close Internet Explorer. The cookie can be read by the Web site that created it when you visit that site again. You can use cookie.setMaxAge(s) to set the cookie to be persistent for 's' seconds. A temporary or session cookie is stored only for your current browsing session, and is deleted from your computer when you close Internet Explorer. You can use cookie.setMaxAge(-1) to set the cookie to be temporary. setMaxAge(): Defines how long the cookie should be stored on the browser's machine. MaxAge value is in unit of second. A negative value tells the browser to not save it to the harddisk. A zero value tells the browser to delete it. |
| |||
| Hi, javax.servlet.http Class Cookie java.lang.Object | +--javax.servlet.http.Cookie All Implemented Interfaces: java.lang.Cloneable public class Cookie extends java.lang.Object implements java.lang.Cloneable Creates a cookie, a small amount of information sent by a servlet to a Web browser, saved by the browser, and later sent back to the server. A cookie's value can uniquely identify a client, so cookies are commonly used for session management. A cookie has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum age, and a version number. Some Web browsers have bugs in how they handle the optional attributes, so use them sparingly to improve the interoperability of your servlets. The servlet sends cookies to the browser by using the HttpServletResponse.addCookie(javax.servlet.http.C ookie) method, which adds fields to HTTP response headers to send cookies to the browser, one at a time. The browser is expected to support 20 cookies for each Web server, 300 cookies total, and may limit cookie size to 4 KB each. The browser returns cookies to the servlet by adding fields to HTTP request headers. Cookies can be retrieved from a request by using the HttpServletRequest.getCookies() method. Several cookies might have the same name but different path attributes. Cookies affect the caching of the Web pages that use them. HTTP 1.0 does not cache pages that use cookies created with this class. This class does not support the cache control defined with HTTP 1.1. This class supports both the Version 0 (by Netscape) and Version 1 (by RFC 2109) cookie specifications. By default, cookies are created using Version 0 to ensure the best interoperability.
__________________ Krishnakumar.S Beware of Everything -that is un true; stick to the Truth shall succeed slowly but steadily |
| |||
| HTTP cookies, or more commonly referred to as Web cookies, tracking cookies or just cookies, are parcels of text sent by a server to a Web client (usually a browser) and then sent back unchanged by the client each time it accesses that server. HTTP cookies are used for authenticating, session tracking (state maintenance), and maintaining specific information about users _______________________ Keyword Research Georgia Health Insurance |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ASP.NET Cookies Overview | KiruthikaSambandam | ASP and ASP.NET Programming | 8 | 05-30-2008 02:10 AM |
| Cookies before start using in php | vigneshgets | PHP Programming | 1 | 01-18-2008 04:18 AM |
| Creating Cookies | pranky | HTML, CSS and Javascript Coding Techniques | 2 | 11-21-2007 05:02 AM |
| Cookies | ragavraj | PHP Programming | 4 | 11-01-2007 12:48 PM |
| Cookies vs. Sessions | vijayanand | PHP Programming | 3 | 08-13-2007 08:36 AM |