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 ...