ICookieContainer
Assembly: ZennoLab.InterfacesLibrary
Full name: ZennoLab.InterfacesLibrary.ProjectModel.ICookieContainer
Represents the container of cookies, that synchronizes with an instance.
This interface can be used in action OwnCode (C# or PHP) of ProjectMaker.
Properties
Domains
Property
Gets collection of cookie’s domains from container.
Example
// get the path to log file
string path = project.LogOptions.LogFile;
// set the path to log file
project.LogOptions.LogFile = "X:\\log.txt";
// enable splitting for log
project.LogOptions.SplitLogByThread = true;
return tmp;Methods
Create
Method
Creates a new cookie item.
Parameters
| Параметр | Описание |
|---|---|
host | The host of cookie. For example “lessons.zennolab.com”, “.zennolab.com”, etc. |
path | The path of cookie. |
name | The name of cookie. |
value | The value of cookie. |
expiry | The expiry date of cookie. |
isSecure | The secure flag of cookie. |
isHttpOnly | The httpOnly flag of cookie. |
isSession | The session flag of cookie. |
Returns: New cookie item object.
Example
// create new cookie item
var item = project.Profile.CookieContainer.Create(".zennolab.com", "/", "asd", "123", DateTime.Now.AddYears(1), false, false, false);
// add item to container
project.Profile.CookieContainer.Add(item);Create
Method
Creates a new cookie item.
Parameters
| Параметр | Описание |
|---|---|
host | The host of cookie. For example “lessons.zennolab.com”, “.zennolab.com”, etc. |
path | The path of cookie. |
name | The name of cookie. |
value | The value of cookie. |
expiry | The expiry date of cookie. |
isSecure | The secure flag of cookie. |
isHttpOnly | The httpOnly flag of cookie. |
isSession | The session flag of cookie. |
sameSite | The sameSite of cookie. The sameSite may take values “Strict”, “Lax”, “None” and “Unspecified”. Default value is “Unspecified”. |
priority | The priority of cookie. The priority may take values “Low”, “Medium”, “High”. Default value is “Medium”. |
Returns: New cookie item object.
Example
// create new cookie item
var item = project.Profile.CookieContainer.Create(".zennolab.com", "/", "asd", "123", DateTime.Now.AddYears(1), false, false, false, "Strict", "Medium");
// add item to container
project.Profile.CookieContainer.Add(item);Add
Method
Adds the cookie item to the container.
Parameters
| Параметр | Описание |
|---|---|
item | The cookie item. |
Example
// create new cookie item
var item = project.Profile.CookieContainer.Create(".zennolab.com", "/", "asd", "123", DateTime.Now.AddYears(1), false, false, false);
// add item to container
project.Profile.CookieContainer.Add(item);Add
Method
Adds the cookie items collection to the container.
Parameters
| Параметр | Описание |
|---|---|
items | The cookie items collection. |
Example
// create new cookie item
var item = project.Profile.CookieContainer.Create(".zennolab.com", "/", "asd", "123", DateTime.Now.AddYears(1), false, false, false);
var item2 = project.Profile.CookieContainer.Create(".zennolab.com", "/", "qwe", "zxc", DateTime.Now.AddYears(1), false, false, false);
// add item to container
project.Profile.CookieContainer.Add(new [] { item, item2 });Add
Method
Adds the contents of an another container to the container.
Parameters
| Параметр | Описание |
|---|---|
container | The cookie container. |
Example
// create new cookie container
var container = new CookieContainer();
// use new cookie container for http request
ZennoPoster.HTTP.Request(InterfacesLibrary.Enums.Http.HttpMethod.GET, "https://zennolab.com", cookieContainer: container);
// add the contents of the new container to profile's container
project.Profile.CookieContainer.Add(container);Remove
Method
Removes the cookie item from the container.
Parameters
| Параметр | Описание |
|---|---|
item | The cookie item. |
Example
// http request with cookie container
ZennoPoster.HTTP.Request(InterfacesLibrary.Enums.Http.HttpMethod.GET, "https://zennolab.com", cookieContainer: project.Profile.CookieContainer);
// get avaliable domains for container
var domains = project.Profile.CookieContainer.Domains;
if (domains.Count() > 0)
{
var items = project.Profile.CookieContainer.Get(domains.First());
// remove some cookie from container
project.Profile.CookieContainer.Remove(items.FirstOrDefault());
}Remove
Method
Removes the cookie items collection from the container.
Parameters
| Параметр | Описание |
|---|---|
items | The cookie items collection. |
Example
// http request with cookie container
ZennoPoster.HTTP.Request(InterfacesLibrary.Enums.Http.HttpMethod.GET, "https://zennolab.com", cookieContainer: project.Profile.CookieContainer);
// get avaliable domains for container
var domains = project.Profile.CookieContainer.Domains;
if (domains.Count() > 0)
{
var items = project.Profile.CookieContainer.Get(domains.First());
// remove some cookies from container
project.Profile.CookieContainer.Remove(items);
}Remove
Method
Removes the contents of an another container from the container.
Parameters
| Параметр | Описание |
|---|---|
container | The cookie container. |
Example
// create new cookie container
var container = new CookieContainer();
// use new cookie container for http request
ZennoPoster.HTTP.Request(InterfacesLibrary.Enums.Http.HttpMethod.GET, "https://zennolab.com", cookieContainer: container);
// remove the contents of the new container from profile's container
project.Profile.CookieContainer.Remove(container);Clear
Method
Clears the contents from the container.
Clear
Method
Clears the contents from the container.
Parameters
| Параметр | Описание |
|---|---|
domainFilter | The regular expressions for filtering by domain. If value is null or empty string, then method clears cookies for all domains. The default value is empty string. |
Refresh
Method
Replaces the contents of the container with cookies from the instance. Works only for project.Profile.CookieContainer.
Get
Method
Gets a collection of cookie items corresponding to the host.
Parameters
| Параметр | Описание |
|---|---|
host | The host. |
Returns: The cookie items collection.
Example
// http request
ZennoPoster.HTTP.Request(InterfacesLibrary.Enums.Http.HttpMethod.GET, "https://zennolab.com", cookieContainer: project.Profile.CookieContainer);
// get cookie items
var items = project.Profile.CookieContainer.Get("zennolab.com");
// output to log info of cookie item
foreach(var item in items)
{
project.SendInfoToLog(item.Name + " = " + item.Value);
}GetPairs
Method
Gets a collection of cookie strings corresponding to the host. Format is “name=value”
Parameters
| Параметр | Описание |
|---|---|
host | The host. |
Returns: The cookie strings collection.
Example
// http request
ZennoPoster.HTTP.Request(InterfacesLibrary.Enums.Http.HttpMethod.GET, "https://zennolab.com", cookieContainer: project.Profile.CookieContainer);
// get cookie items
var items = project.Profile.CookieContainer.GetPairs("zennolab.com");
// output to log info of cookie item
foreach(var item in items)
{
project.SendInfoToLog(item);
}Get
Method
Gets a collection of cookie items corresponding to the host and path.
Parameters
| Параметр | Описание |
|---|---|
host | The host. |
path | The path. |
Returns: The cookie items collection.
Example
// http request
ZennoPoster.HTTP.Request(InterfacesLibrary.Enums.Http.HttpMethod.GET, "https://zennolab.com", cookieContainer: project.Profile.CookieContainer);
// get cookie items
var items = project.Profile.CookieContainer.Get("zennolab.com", "/");
// output to log info of cookie item
foreach(var item in items)
{
project.SendInfoToLog(item.Name + " = " + item.Value);
}GetPairs
Method
Gets a collection of cookie strings corresponding to the host and path. Format is “name=value”
Parameters
| Параметр | Описание |
|---|---|
host | The host. |
path | The path. |
Returns: The cookie strings collection.
Example
// http request
ZennoPoster.HTTP.Request(InterfacesLibrary.Enums.Http.HttpMethod.GET, "https://zennolab.com", cookieContainer: project.Profile.CookieContainer);
// get cookie items
var items = project.Profile.CookieContainer.GetPairs("zennolab.com", "/");
// output to log info of cookie item
foreach(var item in items)
{
project.SendInfoToLog(item);
}Get
Method
Gets a collection of cookie items corresponding to the host, path and secure flag.
Parameters
| Параметр | Описание |
|---|---|
host | The host. |
path | The path. |
isSecure | The secure flag. The cookie item does not correspond to the isSecure flag if isSecure = false and item.IsSecure = true, otherwise, it correspond. |
Returns: The cookie items collection.
Example
// http request
ZennoPoster.HTTP.Request(InterfacesLibrary.Enums.Http.HttpMethod.GET, "https://zennolab.com", cookieContainer: project.Profile.CookieContainer);
// get cookie items
var items = project.Profile.CookieContainer.Get("zennolab.com", "/", false);
// output to log info of cookie item
foreach(var item in items)
{
project.SendInfoToLog(item.Name + " = " + item.Value);
}GetPairs
Method
Gets a collection of cookie strings corresponding to the host, path and secure flag. Format is “name=value”
Parameters
| Параметр | Описание |
|---|---|
host | The host. |
path | The path. |
isSecure | The secure flag. The cookie item does not correspond to the isSecure flag if isSecure = false and item.IsSecure = true, otherwise, it correspond. |
Returns: The cookie strings collection.
Example
// http request
ZennoPoster.HTTP.Request(InterfacesLibrary.Enums.Http.HttpMethod.GET, "https://zennolab.com", cookieContainer: project.Profile.CookieContainer);
// get cookie items
var items = project.Profile.CookieContainer.GetPairs("zennolab.com", "/", false);
// output to log info of cookie item
foreach(var item in items)
{
project.SendInfoToLog(item);
}Export
Method
Exports the contents of container to the byte array.
Returns: The byte array representing the contents.
Import
Method
Imports the contents from the byte array.
Parameters
| Параметр | Описание |
|---|---|
cookies | The byte array representing the contents. |