Barracuda Application Server C/C++ Reference
NO
HttpCookie Struct Reference

Detailed Description

A cookie is used for exchanging a small amount of information between a HttpPage and a web browser.

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.

The cookie implementation is almost identical to the cookie implementation in the JavaTM Enterprise Edition

Typical usage:

HttpCookie* cookie = request->getCookie("myCookie");
if( ! cookie ) //If no cookie set for this page
{ //Create a session cookie
cookie = reply->createCookie("myCookie");
//Active cookie i.e. send cookie to client
cookie->activate();
}
//This will never fail
baAssert(cookie == request->getCookie("myCookie"));

#include <HttpServer.h>

Public Member Functions

const char * getComment () const
 Returns the comment set for this cookie or null if the cookie comment is not set.
 
const char * getDomain () const
 Returns the domain name set for this cookie.
 
BaTime getMaxAge () const
 Returns the maximum age of the cookie, specified in seconds; by default, 0 indicating the cookie will persist until browser shutdown.
 
const char * getName () const
 Returns the name of the cookie.
 
const char * getPath () const
 Returns the path on the server to which the browser returns this cookie.
 
bool getSecure () const
 Returns true if the browser is sending cookies only over a secure protocol, or false if the browser can send cookies using any protocol.
 
bool getHttpOnly () const
 Return the HttpOnly attribute. More...
 
const char * getValue () const
 Returns the value of the cookie.
 
void setComment (const char *purpose)
 Specifies a comment that describes a cookie's purpose.
 
void setDomain (const char *pattern)
 Specifies the domain within which this cookie should be presented.
 
void setMaxAge (BaTime expiry)
 Sets the maximum age of the cookie in seconds. More...
 
void deleteCookie ()
 Specifies a path for the cookie to which the client should return the cookie. More...
 
void setPath (const char *uri)
 Set the cookie path.
 
void setSecure (bool flag)
 Inform the browser whether the cookie should be sent only using a secure protocol such as HTTPS – i.e. More...
 
void setHttpOnly (bool flag)
 Marks or unmarks this Cookie as HttpOnly. More...
 
void setValue (const char *newValue)
 Assigns a new value to a cookie after the cookie is created.
 
void activate ()
 Activates the cookie. More...
 

Member Function Documentation

◆ getHttpOnly()

bool HttpCookie::getHttpOnly ( ) const

Return the HttpOnly attribute.

See also
setHttpOnly.
HttpCookie::activate
void activate()
Activates the cookie.
Definition: HttpServer.h:691
HttpCookie
A cookie is used for exchanging a small amount of information between a HttpPage and a web browser.
Definition: HttpServer.h:527
HttpRequest::getCookie
HttpCookie * getCookie(const char *name)
Returns the requested cookie or NULL if no cookie matches the name.
Definition: HttpServer.h:1140