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 Developer
Posts: 4
Registered: ‎08-21-2008
My Device: Not Specified

Set & Get blackberry browser cookies programatically

Hello All,

 

Can we set and get blackberry browser cookies programmatically ? Also where does cookies store in blackberry device? Please provide any links or codes if any.

 

Thanks in advance

 

Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Set & Get blackberry browser cookies programatically

Someone from RIM will have to comment but probably these are kept secret for security issues. I have written a custom browser

and had to do cookie handling myself. You need to go to some length to avoid allowing certain kinds of cookies etc

and I'm not sure there is much real need for external access to a cookie store. If by programmatic you mean javascript,

this does work AFAIK. I'm not sure this link is right but it may help,

 

//   http://www.w3.org/Protocols/rfc2109/rfc2109
// 1) validate domain
// 2) sort path depth
// 3) check expiration
// 4) dup names

 

 This link is dead but I was able to use curl cookie file to get a few things sorted out,maybe you could look up

the header terms, FWIW.

 

# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.

.yahoo.com      TRUE    /       FALSE   2127585600      B       fsbmve54c55iu&b=4&d=kbcQlyhpYEIyyO9DG0d1Q4ssSyQXpc_iuYydJw--&s=jm

BlackBerry Development Advisor
Posts: 15,693
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Set & Get blackberry browser cookies programatically

It is not possible to programmatically access cookies for the BlackBerry Browser from a Java application.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Set & Get blackberry browser cookies programatically

Not that it matters, but just to be clear, how then are the cookies stored? I thought they were just in

persistent storage with a secret hash code or secured by existing API's? Is your browser implemented

largely as native code? Of course it is always possible to share the data, just not allowed.

New Developer
Posts: 4
Registered: ‎08-21-2008
My Device: Not Specified

Re: Set & Get blackberry browser cookies programatically

Actually I m developing application in BB which connect to web service which is hotsted on windows authenticated server. So when I tries to connect to web service it asks me windows user name and password. once user id and password enters my application works fine. But this works for 30-40 mins. Once session expired again need to login to web service by entering windows user id and password.

 

So I was thinking that I could programatically set the windows user Id and password in cookies before launching the application to work smoothly.

 

Is there any way to connect to windows authenticated web service through device by passing windows user id and password programatically ?

 

Thanks in advance

BlackBerry Development Advisor
Posts: 15,693
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Set & Get blackberry browser cookies programatically

You could make a standard HTTP connection, supply the login information required and then handle the cookies within your application.  The cookies should be sent to your application in the HTTP request.  You could read and store them in your application and then send then back to the server with future HTTP requests.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Highlighted
Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Set & Get blackberry browser cookies programatically

Normally cookies are set by the server to keep track of your identity without personal information.

While it is possible a cookie could be very dumb, and the server could just accept it, I don't think that

will help you here. Normally, you send credentials over https and get back a cookie. Even if you could

fake out or reproduce the cookie, the server would still presumably determine if it was expired.

 

When I do this with things like curl, the strategy is usually to post credentials to a form, get back the

cookies and send those with subsequent requests.

You may be able to add an Authorization header but I've never actually tried this,  

 

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

 

 

http://social.msdn.microsoft.com/Forums/en-US/ssdsgetstarted/thread/7034eb1e-c64f-4731-95c9-d31eb17b...