Module Cookies allows the programmer to perform some basic operations on the HTTP cookie database. The cookie database contain client-side state that web servers have requested WebL to store for them. By default the cookie database starts out empty with each WebL run, and fills up as cookies are set. At the end of the run, the cookie database is discarded. This is the default WebL behavior, and no programmer action is required.
The contents of the cookie database can be overriden by specifying a non-nil "Cookie" header field as part of the GetURL and PostURL functions. Furthermore, the Save and Load functions of the Cookie module can be used to save the database to a file, and later load it again. These functions are required if the cookie database is to transcend a single WebL session.
The external file format of the cookie database is a line per cookie, where each cookie is stored in the same format as received in the "Set-cookie" HTTP header. More details about the HTTP Set-cookie header can be found in the cookie specification from Netscape.
By default, the cookie database is shared by all threads and web requests of the WebL process. However, it is sometimes useful to have groups of requests using logically separate cookie databases. WebL allows you to specify which cookie database to use for each web request (and if no database is specified, the default shared cookie database is used). Cookie databases have programmer defined names (strings), and are automatically allocated whenever they are first used. In particular, the "cookiedb" field of the options parameter to GetURL and PostURL functions, specify which cookie database is to be used for that requests. For example, the following web request reads (and also writes) cookies from and to a database called "DB1".
GetURL("http://www.abc.com", nil, nil,
The default cookie database is used when no "cookiedb" option is specified or the database name is the empty string. Note that, as explained before, all cookie databases are discarded after the WebL program ends i.e. the databases are not stored to disk. If you need this functionality, the Load and Save functions of the Cookie module allows you to read and write cookie databases from and to file storage.
|
Adds the cookies in filename to the default cookie database. |
|
|
Adds the cookies in filename to the cookie database named database. |
|