DBA Data[Home] [Help]

PACKAGE: OWAPUB.OWA_COOKIE

Source


1 package OWA_COOKIE is
2 
3    -- These procedures/functions are merely wrappers around
4    -- calls to send an HTTP_COOKIE and to get an HTTP_COOKIE.
5    -- One should be familiar with the specification for
6    -- HTTP cookies before attempting to use these subprograms.
7 
8    -- The HTTP specification for a COOKIE indicates that it
9    -- cookie name/value pairs should not exceed 4k in size.
10    type vc_arr is table of varchar2(4096) index by binary_integer;
11 
12    -- structure for cookies, as you could have multiple values
13    -- associated with a single cookie name.
14    type cookie is RECORD
15    (
16       name     varchar2(4096),
17       vals     vc_arr,
18       num_vals integer
19    );
20 
21    -- Calls to the procedure SEND generate an HTTP header line
22    -- of the form:
23    -- Set-Cookie: <name>=<value> expires=<expires> path=<path>
24    --             domain=<domain> [secure]
25    -- Only the name and value are required (as per the HTTP_COOKIE spec),
26    -- and the default is non-secure.
27    -- Calls to SEND must fall in the context of an OWA procedure's
28    -- HTTP header output.  For example:
29 
30    -- begin
31    --    owa_util.mime_header('text/html', FALSE);
32    --                -- FALSE indicates not to close the header
33    --    owa_cookie.send('ITEM1','SOCKS');
34    --    owa_cookie.send('ITEM2','SHOES');
35    --    owa_util.http_header_close;
36    --
37    --    -- Now output the page the user will see.
38    --    htp.htmlOpen;
39    --    <etc>
40    procedure send(name    in varchar2,
41                   value   in varchar2,
42                   expires in date     DEFAULT NULL,
43                   path    in varchar2 DEFAULT NULL,
44                   domain  in varchar2 DEFAULT NULL,
45                   secure  in varchar2 DEFAULT NULL);
46 
47    -- GET will return an OWA_COOKIE.COOKIE structure
48    -- for the specified cookie name.
49    function get(name in varchar2) return cookie;
50 
51    -- REMOVE will simply force the expiration of an existing cookie.
52    -- This call must come within the context of an HTTP header.
53    -- See the definition of SEND above.
54    -- REMOVE generates a line which looks like:
55    -- Set-Cookie: <name>=<value> expires=01-JAN-1990
56    procedure remove(name in varchar2,
57                     val  in varchar2,
58                     path in varchar2 DEFAULT NULL);
59 
60    -- GET_ALL returns an array of name/value pairs of all HTTP_COOKIES
61    -- sent from the browser.  The name/value pairs appear in the order
62    -- that they were sent from the browser.
63    procedure get_all(names    out vc_arr,
64                      vals     out vc_arr,
65                      num_vals out integer);
66 end;