Sets the cookies (on macOS) to be sent as part of a GET or POST request.
TURL_SetCookies ( switches ; cookiesText )
|switches||not used, reserved for future use. Leave blank or put "-unused"|
|cookiesText||the text of the cookies. Separate each cookie with a semicolon|
Data type returned
If successful this function returns 0. If unsuccessful it returns an error code starting with $$ followed by the error code. Returned error codes can be:
|$$-92||length of the cookies text is too long|
|$$-4221||this function does not do anything on Windows|
Troi URL Plug-in 1.2
FileMaker Pro 16 to 19
The cookie text is remembered until you specify a different cookie text. If you want to remove a previously specified cookie text, call this function with an empty cookie text.
The cookie text is also removed when you quit FileMaker Pro. The maximum length of a cookie text is 1 Gb.
To see which cookies are set by a web server add the switch “-ReturnHeader” to the TURL_Get or TURL_Post functions of the web page.
On Windows cookies are handled natively by the operating system. So this function does not do anything on this platform.
Note: to view cookies on Windows open the control panel “Internet Options”. Then click on the Settings button in the section “Temporary Internet files” under the General tab. Click on the View Files button to see the cookie files.
See also http://www.howstuffworks.com/cookie1.htm for an explanation on how cookies work.
Set Field [ result ; TURL_SetCookies ( "-unused " ; "troicookie=aap ; plunk=A32" ) ]
This will send the 2 cookies with each subsequent request.
Set Field [ result ; TURL_SetCookies ( "-unused" ; "" ) ]
This will clear the cookie text. No cookies will be sent with a request.
To find out which cookies to send we first return the headers of a web page in the TURL_Get or TURL_Post functions. In this case we get the home page of Amazon:
Set Field [ result ; TURL_Get ( "-ReturnHeader" ; "http://www.amazon.com/" ) ]
This will result in something similar to this (simplified) page:
HTTP/1.1 200 OK Date: Mon, 31 Mar 2003 16:05:33 GMT Server: Stronghold Set-Cookie: session-id=104-1127-69752; path=/; domain=.amazon.com; expires=Monday, 07-Apr-2003 08:00:00 GMT Set-Cookie: session-id-time=1049400; path=/; domain=.amazon.com; expires=Monday, 07-Apr-2003 08:00:00 GMT Set-Cookie: obidos_path_continue-shopping=continue-shopping-url=/home.html/104-123397; path=/; domain=.amazon.com Connection: close Content-Type: text/html <html> ...</hmtl>
Each line that starts with “Set-Cookie:” is a request of the web server to set a cookie on this computer. In this case there are 3 cookies being set. If you want to send those 3 in the next request add this script step before the next GET or POST request:
Set Field [ gErrorCode ; TURL_SetCookies ("-unused" ; "session-id=104-1127-69752 ; session-id-time=1049400 ; obidos_path_continue-shopping=continue-shopping-url=/home.html/104-123397" ) ]