BBjCookie
Description
In BBj 12.00 and higher, BBjCookie 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 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.
Creation
BBxServletContext > BBxServletResponse > BBjCookie
A BBjCookie object is obtained with the following BBxServletResponse method:
Return Value | Method |
---|---|
BBjCookie | createCookie(string name) |
Deprecated Creation
BBjServletEvent > BBjHttpResponse > BBjCookie
Return Value | Method |
---|---|
BBjCookie | BBjHttpResponse::addCookie(string name) |
BBjCookie | BBjspWebResponse::createCookie(string name) |
Methods of BBjCookie
Return Value | Method |
---|---|
string | getComment() |
string | getDomain() |
int | getMaxAge() |
string | getName() |
string | getPath() |
boolean | getSecure() |
string | getValue() |
int | getVersion() |
boolean | isHttpOnly() |
void | setComment(string purpose) |
void | setDomain(string domain) |
void | setHttpOnly(boolean value) |
void | setMaxAge(int expiry) |
void | setPath(string uri) |
void | setSecure(boolean secure) |
void | setValue(string value) |
void | setVersion(int version) |
Remarks
The browser returns cookies to the servlet by adding fields to HTTP request headers. Cookies can be retrieved from a request by using the BBxServletRequest::getCookies() method. Several cookies might have the same name but different path attributes.
Example
See Also
See the BBj Object Diagram for an illustration of the relationship between BBj Objects.