Read a specific cookie from webview

Hi,
I have webview that point to a webpage. In this webpage i set 3 cookies: name, surname, age.
What i want is to read only one specific cookie. ie: name.
I was able to read cookies but all together… how to read just the specific “name” one?

one of the webview extensions might be able to do it...
you can find the extensins directory here App Inventor Extensions | Pura Vida Apps
just search for webview

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

thanks, i used the extension by lucas but this can show all cookies… i need to select just one specific name…
any help?

you might want to show your blocks and the result from the method you are using...
probably you can extract the information you need from that result?

Taifun

do you ha idea how to do? some example?

sorry, I do not have an example, I never used that extension…
well, you said, you are using it… so what about trying to get all cookies and show us the result?

Taifun

This extension: WebViewCookieTools Extension

returns the cookies as a string, each cookie separated by a semi-colon. The example below shows the cookies for https://www.google.co.uk

SID=swePh1UiYTIYFhSjcjMS3vhAXoZVUr_Bu-X3EnKWe1vZRpl_UQ5_0HEIucnqunLEyiiSfA.; _Secure-3PSID=swePh1UiYTIYFhSjcjMS3vhAXoZVUr_Bu-X3EnKWe1vZRpl_Awra2e8oBTmVSWL71deiCQ.; HSID=AgE6BuAiyjtNt--p; SSID=ARaQw3A8Pt8cHlbSa; APISID=FYTzW8FxK8SszQl-/ATAKHikPoL36MNq3V; SAPISID=SEBe47olYXu8-FNk/AwSTHteYdeEIuvVHW; _Secure-HSID=AgE6BuAiyjtNt--p; __Secure-SSID=ARaQw3A8Pt8cHlbSa; __Secure-APISID=FYTzW8FxK8SszQl-/ATAKHikPoL36MNq3V; __Secure-3PAPISID=SEBe47olYXu8-FNk/AwSTHteYdeEIuvVHW; 1P_JAR=2020-04-14-22; OGPC=19016260-1:; NID=202=r3uZTjj3yaYDZAhD-fLhvRFM8-4P16ZyF75qIBiU2fMusaJkEHCMoazo1mNVOL_8QYJrbvUkf7JI0S7ILMwsIN9E0R9bgrVwlWQL3D8YEIbT-Mqs_vfiS5hMem6s42KxKawtcEPw61lHTUDddgGaSvboinzOFmSNeWmVaJHEmVA; OGP=-19016260:

It is then easy enough to split the string by the semi-colon (or maybe: semi-colon+space) to get a list, and return the required cookie.

this sounds good.
Can you pls help me to split it?
For example, let’s image i need the cookie called _ Secure-3PSID
can you pls send me the code how to split?
Thanks a lot friend

Read the documentation on how to use the text split block

http://ai2.appinventor.mit.edu/reference/blocks/text.html#split

If is in list block

If you haven’t done it already…
Read:  The FAQ  TUTORIALS  USING IMAGES  BLOCKS  COMPONENTS  EXTENSIONS  LISTS 

i saw this tutorial but in “thing” elements it add number while i have to search strings and in particular part of strings…
doesn’t work :frowning:

Which tutorial ?

point 6
https://www.imagnity.com/tutorials/app-inventor/list-blocks-on-app-inventor/

Partial searching:

image

returns the index of the first found match

thanks, this works for me but now i have an additional error.
You generate the list by using a make a list block. Good.
In my case the list comes from a set of cookies from webview.

Just to let you understand i add the aia file.
In the remote url i added a php page that save 3 cookies:
name=marco,
surname=m75sa
age=25

try now to search part of a cookie (i.e. arc or 75)… you will see an error

Try like this:

Also, please do not use Kodular for development on the AI2 forum. If you want to use Kodular, fine, but ask questions on the Kodular forum. The distributions are not the same.

1 Like

thanks a lot, all clear now!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.