BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 06-18-2010, 01:00 PM   #1
doom777
New Member
 
Join Date: Jun 2010
Model: 8300
PIN: N/A
Carrier: ATT
Posts: 9
Default Cookie Management in Java applications

Please Login to Remove!

While your program will work in simulator, you actually have to manage yuor cookies in yuor app, since it won't work otherwise on the actual device. The reason, is that MDS manages cookies for you, however on the device, there is no MDS.

Thus, managing your request yuo have to write something like:
Code:
if(this.cookie != null) _connection.setRequestHeader("Cookie", this.cookie);
and managing the response:
Code:
this.cookie = _connection.getHeaderField("Set-Cookie");
Offline  
Old 06-22-2010, 12:37 AM   #2
anuj866
Knows Where the Search Button Is
 
Join Date: Feb 2010
Model: 7100t
PIN: N/A
Carrier: VODAFONE
Posts: 18
Default

i've just done the way you've mentioned above but now the response given from the server is multiple cookies( two cookies are sent)
these two cookies can be easily viewed from a browser which are as below
cookie: login=3
cookie: logincookies= <some session id>

but on device when i performed debug i came to know that the device receives the first cookie(i.e. login=3) twice(duplicated) instead of two different cookies

both of these cookies are required for me to use in the webservice, do you have any clue as to where am i going wrong.
let me know bro.
Offline  
Old 07-06-2010, 07:16 AM   #3
ebaskoro
New Member
 
Join Date: Jul 2009
Location: Jakarta
Model: 8320
OS: v4.5
PIN: N/A
Carrier: XL
Posts: 3
Post

Quote:
Originally Posted by doom777 View Post
Code:
this.cookie = _connection.getHeaderField("Set-Cookie");
Bad idea!

Use the following instead:

Code:
for (int i = 0; _connection.getHeaderFieldKey(i) != null; i ++) {
   String headerKey = _connection.getHeaderFieldKey(i);

   if (headerKey.equalsIgnoreCase("set-cookie")) {
      String cookie = _connection.getHeaderField(i);
      // process or save the cookie
   }
}
Otherwise you will return the same string.
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Radiomatic Flo-One Beta Radio-Chromatography Detector A-500 Model A525 [E2FL] picture

Radiomatic Flo-One Beta Radio-Chromatography Detector A-500 Model A525 [E2FL]

$245.00



New Greaseweazle V4.1 USB Floppy Adapter Flux Reader Writer Amiga Atari ST 1591 picture

New Greaseweazle V4.1 USB Floppy Adapter Flux Reader Writer Amiga Atari ST 1591

$28.64



New Greaseweazle V4.1 USB Floppy Adapter Flux Reader Writer Amiga PC Case 1598 picture

New Greaseweazle V4.1 USB Floppy Adapter Flux Reader Writer Amiga PC Case 1598

$36.40



6500/1 A 6502 VARIENT CPU COMMODORE USE IN AMIGA KB & 1520 PLOTTER NMOS NCR NOS picture

6500/1 A 6502 VARIENT CPU COMMODORE USE IN AMIGA KB & 1520 PLOTTER NMOS NCR NOS

$5.89



Mitsubishi FR-A540-0.75K-NA AC DRIVE INVERTER 1 HP 380-480 VAC 50/60 HZ 4.1 AMP  picture

Mitsubishi FR-A540-0.75K-NA AC DRIVE INVERTER 1 HP 380-480 VAC 50/60 HZ 4.1 AMP

$649.99



Mitsubishi A500 Variable Freq. Drive VFD AC Inverter 480V 3 PH 6.7A 3 HP Max picture

Mitsubishi A500 Variable Freq. Drive VFD AC Inverter 480V 3 PH 6.7A 3 HP Max

$299.99







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.