It is really a shame I cannot understant the cookie setting, maybe I
need more time.

But I know the gem of Mechanize can deal with the cookie quite well,
such as the code:
agent.cookie_jar.save_as('cookie.txt',:cookiestxt)
------
agent.cookie_jar.load('cookie.txt',:cookiestxt)

Is there a way to pass the cookie or the browser instance between
Watir and Mechanize?

Many thanks.

On 11月12日, 上午7时28分, jnxgn <[EMAIL PROTECTED]> wrote:
> Tony,
>
> Thank you very much for your suggestion.
>
> On 11月12日, 上午2时35分, Tony <[EMAIL PROTECTED]> wrote:
>
> > Like Alex had said, its not that simple to add a cookie and get the
> > cookie details by using ie77.document.cookie = tmpcookie.
>
> > A cookie is set by the server and has 3 main identifiers - (name,
> > domain, path) if any of these 3 identifiers are different, a new
> > cookie is created.
> > There are a few limits when you try to access a cookie using document.
>
> > Will explain it to you using an example -
> > clear all cookies and start ie and go to google.com.
> > After this run "javascript: alert(document.cookie);" in the url field.
> > You would see something like -
> > "PREF=ID=80fb690664c20f44:TM=1226473461:LM..."
> > What this actually means is there is a cookie with name: PREF and
> > value: ID=80fb690664c20f44:TM=1226473461:LM...
> > This shows only one cookie is set. But actually 2 cookies were set,
> > one is for google.com domain and the other google.co.in (cause iam in
> > India and google does a redirect to google.co.in).
>
> > We can't access the cookie for google.com unless iam at the
> > google.com. document.cookie will only display cookies that are
> > accessible by the domain that served the current page. If iam at
> > google.co.in only cookies of this site are shown and not from msn or
> > yahoo or aol.
>
> > So now you have got the name and value, what about the domain and
> > path ... path most of time by default is "/".
> > Domain would be for which domains this cookie would be sent out to. in
> > this case its .google.co.in
>
> > Now there is also an expiry date which mentions if the cookie is a
> > session cookie or not.
>
> > ie77.document.cookie will return n number of cookies with a ; as
> > delimiter.
> > But this may not be returning you everything you need. For example the
> > path of a cookie in mail.google.com is "/mail"
> > You need to set this too.
>
> > Suggestion is login to your application and check all the cookies that
> > being set for each domain etc using firefox or a proxy.
> > And then try setting your cookie with specific details not just the
> > name and value.
> > Here is a good read to read and set cookies 
> > -http://www.htmlgoodies.com/beyond/javascript/article.php/3470821
>
> > -Tony
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to