[twill] set cookie during script

Jesse London jesselondon at gmail.com
Wed May 13 09:03:59 PDT 2009


Hi Norman,
I'm not sure if you're using the Twill commands module, the Browser object,
or twill-sh; but it looks like regardless there're both the methods
"save_cookies" and "load_cookies" -- the former saves the contents of your
cookie jar to a file, and the latter replaces your cookie jar's contents
with those of a file.

Unfortunately, that means you can't just "insert" a cookie, as far as I can
tell.  But, to get the functionality you want, I believe you can:
1) use "save_cookies /some/path" to save your already-loaded cookies to an
existing (empty) file
2) append the new cookie to that file
3) use "load_cookies /some/path" to load all the cookies back into your jar

Of course, especially if the cookie you want to insert is static, you could
set up your file with it initially, and see if Twill is nice enough to not
overwrite it with save_cookies.

If you are doing this entirely in twill-sh, though, you're operating outside
of what I'm really familiar with, and there might be some parts you'll have
to do in Python (with the "run" command -- e.g. step 2).

Good luck,
Jesse


On Tue, May 12, 2009 at 6:06 PM, Norman Khine <norman at khine.net> wrote:

> Hi,
> I have the latest twill setup and all works well, but have a question
> concerning cookies.
> On a page, I would like to insert a specific cookie, and at the same
> time keep the cookies that are already loaded. Is there a way to do
> this?
> For example, the cookie I want to set is:
>
> Set-Cookie3: tmain_referrer="http://localhost/index.php" path="/";
> domain="localhost"; path_spec; discard; version=0
>
> Thanks
> Norman
>
> _______________________________________________
> twill mailing list
> twill at lists.idyll.org
> http://lists.idyll.org/listinfo/twill
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.idyll.org/pipermail/twill/attachments/20090513/6ae9e12b/attachment.htm 


More information about the twill mailing list