Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
waksmann
Posts: 4
Registered: ‎12-25-2011
My Device: 9800 simulator

Trouble with cookies

Hey forum,

I'm trying to write a new program for BB using JRE 6.0 in which the user is able to sign in using Google openID.

At first I'm sending a request for my server to get the google url so it can keep the session then

I'm loading the url using BrowserField, let the user enter his details and in the end of the process I get the session ID.

the trouble occurs when another user trying to log in using the same app - the BrowserField/BB saving some cookies about the user and instead of his sign in screen, Google automaticly give me the previous user session.

 

// Getting Google URL
strData = new AccountServerDA().getOpenIDUrl(strProvider,strEmail);

// Trying to set a cookie
BrowserFieldCookieManager cookieMan = myBrowserField.getCookieManager();
Dialog.alert("Current Cookie: " + cookieMan.getCookie(strData));
cookieMan.setCookie(strData, "");
Dialog.alert("New Cookie: " + cookieMan.getCookie(strData));

myBrowserField.setFocus();
myBrowserField.requestContent(strData);

I tried doing .refresh(), setting a new cookie using CookieManager (as you can see in the example) and also asking for requestContent with Hashtable holding an empty cookie. none of those methods helped.

As anyone got an idea how can I delete/replace those cookies and let a new user use the openid screen?

 

Much obliged,

Yaniv

New Contributor
waksmann
Posts: 4
Registered: ‎12-25-2011
My Device: 9800 simulator

Re: Trouble with cookies

Oh, and deleting the field and creating it again doesn't help as well.

Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Trouble with cookies

[ Edited ]

Hi Yaniv,

 

You can try and initiate the browserField before the second user request:

 

myBrowserField = new BrowserField();

 

Hope that helps,

 

E.

 

[EDIT]

 

Just saw your second post...

 

Have you tried to reset the CookieManager?

 

You can do it using the BrowserFieldConfig object.

 

E.

 

 

New Contributor
waksmann
Posts: 4
Registered: ‎12-25-2011
My Device: 9800 simulator

Re: Trouble with cookies

Thanks maadani. Can you please elaborate on how to reset the CookieManager? I only successed in implmanting a new one but which can't handle cookies so google had to reject my request...

New Contributor
optimus_prime
Posts: 6
Registered: ‎05-08-2012
My Device: BB 9800

Re: Trouble with cookies

Hi ,

 

I am stuck with the same issue.

 

i am unable to clear cookies in the browserfield's cookieManager.  Creating a new instance of BrowserField did not help, because if i do  newInstanceBF.getcookieManager() will still give me all the existing cookies.

 

How can i flush all the cookies ?  Please suggest 

 

Thanks.