How to read a value in a cookie?

Aronax

Client
Регистрация
29.01.2015
Сообщения
201
Благодарностей
59
Баллы
28
How can I take the value of this cookie and use it in my template? (it is already saved in the zpprofile file)

69186
 

nicanil

Client
Регистрация
06.03.2016
Сообщения
2 242
Благодарностей
1 816
Баллы
113
You can use this simple C# snippet:
return instance.GetCookie("zennolab.com", false);

First parameter (in my example "zennolab.com") - domain for which you want to get cookies
Second - cookie format. You can try both (true or false) to chose the best one for your needs.

Then using Text processing-Regex action you can get cookie value.
 
  • Спасибо
Реакции: Aronax

Aronax

Client
Регистрация
29.01.2015
Сообщения
201
Благодарностей
59
Баллы
28
Thanks [USER = 12819] nicanil [/ USER]. This works well when using a browser instance. But, do you know a way to read the cookies values when no browser is being used (bot with HTTP requests only and loading a profile which is filled with cookies)?
Thanks
 
Последнее редактирование:

nicanil

Client
Регистрация
06.03.2016
Сообщения
2 242
Благодарностей
1 816
Баллы
113
But, do you know a way to read the cookies values when no browser is being used (bot with HTTP requests only and loading a profile which is filled with cookies)?
Try this code:
C#:
var cookies = project.Profile.CookieContainer.GetPairs("zennolab.com");
return String.Join(Environment.NewLine, cookies);
Change zennolab.com to your host.
This snippet will return all cookies related to the specified host in name=value format. Each cookie from new line.
 
  • Спасибо
Реакции: xIIImaL и Aronax

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)