Questions about getting session cookies

5 views
Skip to first unread message

Kevin Cheng

unread,
Sep 3, 2008, 11:04:23 PM9/3/08
to watij
My questions is:
How to get the current process's CookieManager?

Following is my story on indagating the Watij's cookie related
functions:
For some functional requirement, I need to get the session cookies. So
I went through the watij source code, and found that the cookie
related functions are not available so far(Class DummyWB). So I
decided to complete the getCookies(String) function.

From the source code, I learnt that Watij use the JExplorer to deal
with IExplorer. JExplorer is not open source, from its API spec, I
found the CookieManager:
ref: http://www.teamdev.com/downloads/jexplorer/javadoc/com/jniwrapper/win32/ie/cookie/CookieManager.html
Which provides the getCookies(Url) and getPersistentCookies(). The
ideal solution was found I thought. So I added two functions:
getCookies(String), getPersistentCookies() on the class IE:
-----------------------------------------
public Set getCookies(String string) {
try{
return webBrowser.getCookies(string);
//URL url = new URL(string);
//return cookieManager.getCookies(url);
}catch(Exception e){
System.out.println(e.getMessage());
return null;
}
}
-----------------------------------------
Unfortunally, none session cookies were returned, when I ran the
testcase.

JExplorer's function description for getCookies:
-----------------------------------------
getCookies
It also searches memory for any session cookies, that is, cookies
that do not have an expiration date that were created in the same
process by CookieManager.setCookie(), because these cookies are not
written to any files. Rules for creating cookie files are internal to
the system and can change in the future.
Note: The method does not return cookies that the server marked as
non-scriptable with the "HttpOnly" attribute in the Set-Cookie header.
-----------------------------------------

So now I'm wondering whether I have used the same CookieManager or not
with the current IE process.

Are there anyone can give me a suggestion?

Looking forward ...


Alejandro Soini

unread,
Sep 4, 2008, 2:35:20 AM9/4/08
to wa...@googlegroups.com
I'm not sure of the answer but can suggest another possible resource for you to ask the question.  Try on TeamDev's Jexporer forum, I think they have a section designed specifically for Jexplorer.  Good luck.

Kevin Cheng

unread,
Sep 9, 2008, 1:37:13 AM9/9/08
to watij
Thank you all the same.
I'll check the Jexplorer when I have time.

Kevin Cheng

On Sep 4, 2:35 pm, "Alejandro Soini" <alejoso...@gmail.com> wrote:
> I'm not sure of the answer but can suggest another possible resource for you
> to ask the question.  Try on TeamDev's Jexporer forum, I think they have a
> section designed specifically for Jexplorer.  Good luck.
>
> On Wed, Sep 3, 2008 at 8:04 PM, Kevin Cheng <lelechen...@gmail.com> wrote:
>
> > My questions is:
> > How to get the current process's CookieManager?
>
> > Following is my story on indagating the Watij's cookie related
> > functions:
> > For some functional requirement, I need to get the session cookies. So
> > I went through the watij source code, and found that the cookie
> > related functions are not available so far(Class DummyWB). So I
> > decided to complete the getCookies(String) function.
>
> > From the source code, I learnt that Watij use the JExplorer to deal
> > with IExplorer. JExplorer is not open source, from its API spec, I
> > found the CookieManager:
> > ref:
> >http://www.teamdev.com/downloads/jexplorer/javadoc/com/jniwrapper/win...
Reply all
Reply to author
Forward
0 new messages