Passing a cookie as an output in a custom Python node

I am required to create a node that passes a cookie to subsequent nodes in Python. As far as I can see the only outputs you can pass on is a table or a binary object. When logging into the API it returns a typical session with the cookie in a cookiejar object. How would I pass that onto the next node?

Any help will be much appreciated.

Hi @vanzylkruger,
You need to find out how to serialize your cookiejar object and use a binary port. I found a post on StackOverflow on that.

Note, that we will add support for custom port object types with the next release. However, you will need to serialize and deserialize the cookiejar anyways. Nodes are not executed in the same Python process. Therefore, all data transferred between them must be serialized to binary beforehand. Also, ports are meant to be saved to disk with the workflow. Therefore, we need to know how to save them.


Hi @vanzylkruger,

an alternative solution could be to save the cookiejar object into a temporary file using the method and pass the filename as FlowVariable to the next node where you can user FileCookieJar.load() to import the cookies again…


1 Like

Hi @PTDataScientist,

Thanks for the suggestion! Your suggestion does work locally, however it is unfortunately not optimal when you want to share a workflow.

Imagine you share a saved workflow with somebody else, where the flow variable references a temporary file path on your machine. If the person who imports your workflow only re-executes the node receiving the flow variable pointing to a non-existing temp file, loading the cookie won’t work and the node will fail.

The solution @bwilhelm suggested is robust to those things. It allows saved workflows to be shared including the serialized cookies.


@carstenhaubold hello,I understand that you mentioned the geospatial extension. When can I download it from the knime hub. Recently, I often use knit to process and analyze geospatial data. Unfortunately, knime cannot perform geospatial analysis, such as intersection, clipping, spatial location filtering of shapefiles, etc., so I look forward to using geospatial extension earlier. Thank you.

@GISer_last: please stop cross posting. We have already answered your request in your own thread.

1 Like

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