java.lang.Object
javax.servlet.http.Cookie
com.RuntimeCollective.webapps.bean.LoginCookie
- All Implemented Interfaces:
- java.lang.Cloneable
- public class LoginCookie
- extends javax.servlet.http.Cookie
LoginCookie.java
Keeps track of users who want to stay logged in
- Version:
- $Id: LoginCookie.java,v 1.7 2003/09/30 15:13:09 joe Exp $
Portions derived from Marty Hall's Servlet Tutorial:
http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-Cookies.html
(c) 1999 Marty Hall. All source code freely available for unrestricted use.
|
Field Summary |
static java.lang.String |
COOKIE_NAME
The cookie name, to use when storing the cookie on the request. |
static int |
KEY_SIZE
How large the random key should be (must match up with the data model) |
static java.lang.String |
RETURN_URL_NAME
When a user tries to access a page that requires them to be logged on,
this page's URL will be stored in the session under RETURN_URL_NAME |
static int |
SECONDS_PER_YEAR
The cookie persists for a year. |
| Fields inherited from class javax.servlet.http.Cookie |
|
| Methods inherited from class javax.servlet.http.Cookie |
clone, getComment, getDomain, getMaxAge, getName, getPath, getSecure, getValue, getVersion, setComment, setDomain, setMaxAge, setPath, setSecure, setValue, setVersion |
SECONDS_PER_YEAR
public static final int SECONDS_PER_YEAR
- The cookie persists for a year.
- See Also:
- Constant Field Values
COOKIE_NAME
public static final java.lang.String COOKIE_NAME
- The cookie name, to use when storing the cookie on the request.
- See Also:
- Constant Field Values
RETURN_URL_NAME
public static java.lang.String RETURN_URL_NAME
- When a user tries to access a page that requires them to be logged on,
this page's URL will be stored in the session under RETURN_URL_NAME
KEY_SIZE
public static final int KEY_SIZE
- How large the random key should be (must match up with the data model)
- See Also:
- Constant Field Values
LoginCookie
public LoginCookie(java.lang.String name,
java.lang.String value)
- Make a new login cookie. It persists for a year, and is sent to every page on the server.
setCookie
public static void setCookie(User cookieUser,
javax.servlet.http.HttpServletResponse response)
- Sets a login cookie for a user who wants to be permenantly logged on.
removeCookie
public static void removeCookie(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
- Removes the LoginCookie from the given request
getCookieValue
public static java.lang.String getCookieValue(javax.servlet.http.Cookie[] cookies,
java.lang.String cookieName,
java.lang.String defaultValue)
- Gets a specific value from a bunch of cookies
getUser
public static User getUser(javax.servlet.http.Cookie[] cookies)
- Return the User stored in the COOKIE_NAME cookie