CURL.SetOptionCookie
--------------------

Sets the cookie for the current http transfer.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [CURL](component_CURL.md) | [2.5](newinversion25.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "CURL.SetOptionCookie"; curl; Value { ; Encoding } ) 

**MBS**( **"CURL.SetOptionCookie";** /\* Sets the cookie for the current http transfer. \*/  
**$curl**; /\* The CURL session handle. \*/   
**$Value**; /\* The cookie string.e.g. "" \*/   
**$Encoding**) /\* Optional; The text encoding for text parameter.   
Default is UTF-8.e.g. "utf8" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| curl | The CURL session handle. | $curl |  |
| Value | The cookie string. | "" |  |
| Encoding | The text encoding for text parameter.    Default is UTF-8.   Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the [FAQ](https://www.monkeybreadsoftware.com/filemaker/faq.shtml). | "utf8" | Optional |

### Result

Returns "OK" on success.

### Description

Sets the cookie for the current http transfer.  
Pass a cookie string. It will be used to set a cookie in the http request. The format of the string should be NAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookie should contain.  
  
If you need to set multiple cookies, you need to set them all using a single option and thus you need to concatenate them all in one single string. Set multiple cookies in one string like this: "name1=content1; name2=content2;" etc.  
  
This option sets the cookie header explicitly in the outgoing request(s). If multiple requests are done due to authentication, followed redirections or similar, they will all get this cookie passed on.  
  
Using this option multiple times will only make the latest string override the previous ones.  
  
Cookie format is explained here:  
<https://humanwhocodes.com/blog/2009/05/05/http-cookies-explained/>  
See also [COOKIE](https://curl.haxx.se/libcurl/c/CURLOPT_COOKIE.html) option in CURL manual.

### Examples

Pass 4 cookies together:

 MBS ( "CURL.SetOptionCookie"; $curl ; "ORA\_WX\_SESSION="32230CEE0E940BDFA8157FEF3EB58E9CBD8A5699-3#1"; ObSSOCookie=VPAEWqhsUTbSXpHB0%3BqRDXNegpZBgeCgR1GJ3Ysou0A5%3FyUdO0ffMSHUl7fN0mg4cVonDmjnakVdoYpnigAR4mAeWUMk6sLw%3BqwSCmY1bCfxhdWcoOS4NhaifxRazpYpEywzdqQ3kRkNwRpECdBrwWdcFBCo6TROhgEufbykS%3FSYU%3FwJT%3FP95WgkCRMBkJBE2LSk%3B1F2BtBjBGDa42jFR8gK7bE0ewJ%3B1MM6vzq93scwL9NO%3BbCixrvJlGYL8fQWG%3BwewaIRRf4i3IcThDQBHg%2D%2D; JSESSIONID=EPQSsbjcndhPqEtvW8MQS8sQCGWta7QQQMi8k6eiT\_EcoNB\_YOqL!-166722973; ObSSOCookie=ktizpHi8mrSLizEejydmRivWZu%3BHr99%3BVh%3FTLFhIMRweTbStBfibTYNPa%3FpMErio42eAQ30r1SVrTmuTLbI9Cyh3KPAqR5x%3BPs6rQQbRfZrpThhgSuPZzRx7NI9S9gKQYmeWAKkIRETUR9XZKuU1ll7GwK4Ci0QFSwON2sU12EPvns9Y8RFNWHNsdfDpNXn4qdfDvOhP8VnnYNMjvZnq%3Fofg%3Fxd3QfOZnL2Z86riaRz4gq5IeKolxN7iWM4%3FIcYk2nMeEx4A9iRtftPFyGEBWpxxtMG6UsE2RMhLqMpV4Lg%2D"; "UTF-8" )  
### See also

- [CURL.GetCookieList](CURLGetCookieList.md)
- [CURL.SetOptionCookieJar](CURLSetOptionCookieJar.md)
- [CURL.SetOptionHTTPHeader](CURLSetOptionHTTPHeader.md)
- [CURL.SetOptionNoBody](CURLSetOptionNoBody.md)
- [CURL.SetOptionPort](CURLSetOptionPort.md)
- [CURL.SetOptionPost](CURLSetOptionPost.md)
- [CURL.SetOptionProxy](CURLSetOptionProxy.md)
- [CURL.SetOptionQuote](CURLSetOptionQuote.md)
- [CURL.SetOptionRange](CURLSetOptionRange.md)
- [CURL.SetOptionResolve](CURLSetOptionResolve.md)

### Release notes

- **Version 8.0**
    - Changed [CURL.SetOptionCAINFO](http://www.mbsplugins.eu/CURLSetOptionCAINFO.shtml), [CURL.SetOptionCAPATH](http://www.mbsplugins.eu/CURLSetOptionCAPATH.shtml), [CURL.SetOptionCookieFile](http://www.mbsplugins.eu/CURLSetOptionCookieFile.shtml), [CURL.SetOptionCookieJar](http://www.mbsplugins.eu/CURLSetOptionCookieJar.shtml), [CURL.SetOptionIssuerCert](http://www.mbsplugins.eu/CURLSetOptionIssuerCert.shtml), [CURL.SetOptionNETRCFile](http://www.mbsplugins.eu/CURLSetOptionNETRCFile.shtml), [CURL.SetOptionRandomFile](http://www.mbsplugins.eu/CURLSetOptionRandomFile.shtml), [CURL.SetOptionSSHPrivateKeyfile](http://www.mbsplugins.eu/CURLSetOptionSSHPrivateKeyfile.shtml), [CURL.SetOptionSSHPublicKeyfile](http://www.mbsplugins.eu/CURLSetOptionSSHPublicKeyfile.shtml), [CURL.SetOptionSSLCert](http://www.mbsplugins.eu/CURLSetOptionSSLCert.shtml), [CURL.SetOptionSSLKey](http://www.mbsplugins.eu/CURLSetOptionSSLKey.shtml) to use always UTF-8 on Mac/Linux and on Mac do the unicode transformation for decomposed characters to avoid trouble with special characters in file paths.

### Blog Entries

- [Translating Insert from URL options for CURL to MBS Plugin calls](https://www.mbsplugins.de/archive/2020-12-14/Translating_Insert_from_URL_op/monkeybreadsoftware_blog_filemaker)

Created 18th August 2014 , last changed 27th February 2019

  
[CURL.SetOptionConnectionTimeout](CURLSetOptionConnectionTimeout.md) - [CURL.SetOptionCookieFile](CURLSetOptionCookieFile.md)

[HTML Version](CURLSetOptionCookie.shtml)