www.beck-ipc.com

@CHIP-RTOS C Library - Common Gateway Interface API


CGI_SetCookie

Creates a new cookie or modifies an old one.

int CGI_SetCookie ( const char far *name,
                    const char far *value,
                    const char far *domain,
                    const unsigned long far *expires,
                    const char far *path,
                    const int secure,
                    rpCgiPtr CgiRequest);

Parameters

name

Input Parameter:   A pointer to a c-string which represents cookies-name.

value

Input Parameter:   A pointer to a c-string which represents cookies-value.

domain

Input Parameter:   A pointer to a c-string which represents cookies-domain. If you are not interest in the cookie-domain then you can pass a null pointer.

expires

Input Parameter:   A pointer to an unsigned long which represents cookies-expire-time. If you are not interest in the cookie-expire-time then you can pass a null pointer.

path

Input Parameter:   A pointer to a c-string which represents cookies-path. If you are not interest in the cookie-path then you can pass a null pointer.

secure

Input Parameter:   This integer value defines the secure state of the cookie.
0 : no secure cookie
!=0 : secure cookie

CgiRequest

Input Parameter:   The cgi request pointer which was passed to the cgi function.

Return Value

CGI_COOKIE_ERR_OK: Success, the cookie was created
CGI_COOKIE_ERR_SIZE: The cookie parameters in sum are too large. All cookies together must not be larger than 1024 bytes.
CGI_COOKIE_ERR_PARAM: Invalid parameters, e.g. no cookie-name .

Comments

The argument strings are copied internal, so they are not required after the function call and could by deleted or modified.
Note that the date and time and also the timezone have to be set when you are using the expires argument.
This function must be called within the context of a cgi function. The pointers returned by the function are valid only while the cgi function is active. On return from the cgi function the pointer will become invalid.

Example:

            

int result = CGI_SetCookie("username",
                           "otto",
                           NULL,
                           NULL,
                           NULL,
                           0,
                           CgiRequest);
if (result != CGI_COOKIE_ERR_OK)
{
   // ERROR!
}

See Also

Supported since or modified in @CHIP-RTOS version

    SC12SC13SC11SC1x3SC2x
    n/an/an/aV1.15V1.00

Supported by @CHIP-RTOS C Library since version

    CLIB
    V2.10

This API List
List of C Libraries
@CHIP-RTOS Main Index


End of document